Routes dispatching in twisted.web.server
|Reported by:||Zach||Owned by:|
Description (last modified by )
It would be nice to have an option to use Routes-based dispatching in twisted.web.server.
from twisted.web.server import Site class Controller(object): def index(self, request): return '<html><body>Hello World!</body></html>' c = Controller() dispatcher = Dispatcher() dispatcher.connect(name='index', route='/', controller=c, action='index') factory = Site(dispatcher)
You would then also be able to do stuff like this:
from twisted.web.static import File dispatcher.putChild('static', File(static_path))
We could adapt something like https://github.com/steiza/twistedroutes; we're using this for several internal webservices at work and it's quite nice to program in. : )