Flask + Tornado y autoreload
In a application developed with Flask and using Tornado as middleware, I had the need for the useful functionality of auto reloading code changes. So every time I would a make a git push
to the server every code change were immediately available.
I ended up using the following code to autoload changes in the Flask application's source code.
from tornado import autoreload
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from application import app
DEFAULT_APP_TCP_PORT = 5000
http_server = HTTPServer(WSGIContainer(app))
http_server.listen(DEFAULT_APP_TCP_PORT)
ioloop = IOLoop.instance()
autoreload.start(ioloop)
ioloop.start()
Written by Christopher Ramírez
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Flask
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#