[Twisted-Python] twisted vs wsgi

Chris Withers chris at simplistix.co.uk
Tue Mar 30 01:46:29 MDT 2010


Hi All,

I've managed to cobble this together as a way of starting a BFG app 
under Twisted's wsgi server:

"""
from twisted.web.wsgi import WSGIResource
from twisted.web.server import Site
from twisted.internet import reactor

from webob import Response
from repoze.bfg.configuration import Configurator

def hello_world(request):
     return Response('Hello world!')

if __name__ == '__main__':
     config = Configurator()
     config.begin()
     config.add_view(hello_world)
     config.end()

     resource = WSGIResource(reactor, reactor.getThreadPool(),
                             config.make_wsgi_app())
     factory = Site(resource, 'server.log')
     reactor.listenTCP(8080, factory)
     reactor.run()
"""

I struggled to find good narrative docs on using Twisted as a WSGI 
server. Where should I have been looking and have I dropped any clangers 
in the above?

cheers,

Chris





More information about the Twisted-Python mailing list