pythontornadofanstatic

Integrating fanstatic with tornado web?


I'm attempting to integrate fanstatic.org with tornadoweb and was curious if anyone has any prior knowledge or any code that may reflect how this is done? I've been reading the documentation and i believe it can be done since tornado does provide a wsgi interface.

thanks


Solution

  • import tornado.wsgi
    from fanstatic import Fanstatic   
    
    from your_tornado_app import MainHandler # tornado.web.RequestHandler
    
    app = tornado.wsgi.WSGIApplication([
        (r"/", MainHandler),
    ])
    app = Fantastic(app)
    
    if __name__ == '__main__':
        from wsgiref.simple_server import make_server
    
        server = make_server('127.0.0.1', 8080, app)
        server.serve_forever()