Running a Pyramid WSGI application under tornado

别说谁变了你拦得住时间么 提交于 2019-12-06 12:01:27

问题


Pyramid uses it's own Waitress web server for development purposes, but I want to serve my WSGI app under Tornado. I think I should configure it using the pserve .ini files, but I can't get it to work


回答1:


The Pyramid application can be loaded from the INI files easily. From there you just pass the wsgi app into Tornado's WSGIContainer.

from pyramid.paster import get_app

app = get_app('development.ini')
container = tornado.wsgi.WSGIContainer(app)



回答2:


Again, not really recommending running WSGI under Tornado, since it gives you none of the advantages of Tornado.

Should you still want to do it for some reason, the second example of the docs seems to be what you are looking for: http://www.tornadoweb.org/documentation/wsgi.html

def simple_app(environ, start_response):
    status = "200 OK"
    response_headers = [("Content-type", "text/plain")]
    start_response(status, response_headers)
    return ["Hello world!\n"]

container = tornado.wsgi.WSGIContainer(simple_app)
http_server = tornado.httpserver.HTTPServer(container)
http_server.listen(8888)
tornado.ioloop.IOLoop.instance().start()


来源:https://stackoverflow.com/questions/9942188/running-a-pyramid-wsgi-application-under-tornado

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!