Last Updated: February 25, 2016
·
1.46K
· chrramirez

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()