Opened 6 years ago

Closed 4 years ago

#4947 enhancement closed wontfix (wontfix)

Routes dispatching in twisted.web.server

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

Description (last modified by tom.prince)

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; we're using this for several internal webservices at work and it's quite nice to program in. : )

Change History (6)

comment:1 Changed 6 years ago by DefaultCC Plugin

  • Cc jknight added

comment:2 Changed 6 years ago by glyph

  • Description modified (diff)

Fixing markup

comment:3 Changed 6 years ago by glyph

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

comment:4 Changed 6 years ago by steiza

Not at all, you can now find it here:

comment:5 Changed 4 years ago by tom.prince

  • Description modified (diff)
  • Priority changed from normal to low is also related.

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

comment:6 Changed 4 years ago by exarkun

  • Resolution set to wontfix
  • Status changed from new to closed

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.