Ticket #4947 enhancement closed wontfix

Opened 3 years ago

Last modified 15 months ago

Routes dispatching in twisted.web.server

Reported by: steiza Owned by:
Priority: low Milestone:
Component: web Keywords:
Cc: jknight Branch:
Author: Launchpad Bug:

Description (last modified by tom.prince) (diff)

It would be nice to have an option to use Routes-based dispatching in twisted.web.server.

Something like:

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,

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. : )

Change History


Changed 3 years ago by DefaultCC Plugin

  • cc jknight added


Changed 3 years ago by glyph

  • description modified (diff)

Fixing markup


Changed 3 years ago by glyph

Would you mind renaming 'twistedroutes' to 'txroutes' until we include it in the core?


Changed 3 years ago by steiza

Not at all, you can now find it here:  https://github.com/steiza/txroutes


Changed 15 months ago by tom.prince

  • priority changed from normal to low
  • description modified (diff)

 https://github.com/twisted/klein is also related.

I think given the diversity of implementations, this is perhaps something that should live outside twisted proper.


Changed 15 months ago by exarkun

  • status changed from new to closed
  • resolution set to wontfix

Such an API could be part of Twisted, if anyone demonstrates they have a good implementation that a lot of people were happy with, and which many people would benefit from having included in Twisted (simplified deployment story or some implementation enhancement which is only possible by maintaining the code in lockstep with the rest of Twisted Web).

Otherwise there doesn't seem to be much problem caused by distributing these things separately.

Please feel free to re-open in case something qualifies according to my first paragraph.

Note: See TracTickets for help on using tickets.