龙卷风 - 安装瓶应用程序

时间:2012-04-26 08:22:45

标签: python websocket wsgi tornado bottle

如何在Tornado服务器中安装Bottle应用程序? Here is my code

1 个答案:

答案 0 :(得分:2)

bottle.default_app()返回一个WSGI可调用:

if __name__ == "__main__":
    bottle_app = bottle.default_app()
    bottle_handler = tornado.wsgi.WSGIContainer(bottle_app)
    HTTPServer(Application([(r"/ws", WSHandler),
                            (r"/css/(.*)", StaticFileHandler, {"path": "./css/"}),
                            (r"/js/(.*)", StaticFileHandler, {"path": "./js/"}),
                            (r"/img/(.*)", StaticFileHandler, {"path": "./img/"}),
                            ("/(.*)", bottle_handler)])
                         ).listen(1024)
    IOLoop.instance().start()