| 1 |
# Copyright (c) Twisted Matrix Laboratories. |
| 2 |
# See LICENSE for details. |
| 3 |
|
| 4 |
""" |
| 5 |
This demonstrates a web server which can run behind a name-based virtual hosting |
| 6 |
reverse proxy. It decodes modified URLs like: |
| 7 |
|
| 8 |
host:port/vhost/http/external-host:port/ |
| 9 |
|
| 10 |
and dispatches the request as if it had been received on the given protocol, |
| 11 |
external host, and port. |
| 12 |
|
| 13 |
Usage: |
| 14 |
python web.py |
| 15 |
""" |
| 16 |
|
| 17 |
from twisted.internet import reactor |
| 18 |
from twisted.web import script, server, static, twcgi, vhost |
| 19 |
|
| 20 |
root = static.File("static") |
| 21 |
root.processors = { |
| 22 |
".cgi": twcgi.CGIScript, |
| 23 |
".epy": script.PythonScript, |
| 24 |
".rpy": script.ResourceScript, |
| 25 |
} |
| 26 |
root.putChild(b"vhost", vhost.VHostMonsterResource()) |
| 27 |
site = server.Site(root) |
| 28 |
reactor.listenTCP(1999, site) |
| 29 |
reactor.run() |