using Flask and Tornado together?
i think i got 50% of the solution, the cookies are not tested yet, but now i can load Flask application using Tornado, and mixing Tornado + Flask together :)
first here is flasky.py the file where the flask application is:
from flask import Flaskapp = Flask(__name__)@app.route('/flask')def hello_world(): return 'This comes from Flask ^_^'
and then the cyclone.py the file which will load the flask application and the tornado server + a simple tornado application, hope there is no module called "cyclone" ^_^
from tornado.wsgi import WSGIContainerfrom tornado.ioloop import IOLoopfrom tornado.web import FallbackHandler, RequestHandler, Applicationfrom flasky import appclass MainHandler(RequestHandler): def get(self): self.write("This message comes from Tornado ^_^")tr = WSGIContainer(app)application = Application([(r"/tornado", MainHandler),(r".*", FallbackHandler, dict(fallback=tr)),])if __name__ == "__main__": application.listen(8000) IOLoop.instance().start()
hope this will help someone that wants to mix them :)
Based on 1 and 2, the combined and shorter answer is
from flask import Flaskapp = Flask(__name__)@app.route("/")def hello(): return "Hello World!"if __name__ == "__main__": from tornado.wsgi import WSGIContainer from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop http_server = HTTPServer(WSGIContainer(app)) http_server.listen(8000) IOLoop.instance().start()
Please consider the warning about performance that has been mentioned on 2 , 3