Deploying with Tornado
Tornado is a complete web framework and a standalone web server in itself. Here, we will use Flask to create our application, which is a combination of URL routing and templating, and leave the server part to Tornado. Tornado is built to hold thousands of simultaneous standing connections and makes applications very scalable.
Information
Tornado has limitations while working with WSGI applications, so choose wisely! You can read more about this at http://www.tornadoweb.org/en/stable/wsgi.html#running-wsgi-apps-on-tornado-servers.
Getting ready
Installing Tornado can be done using pip
:
$ pip install tornado
How to do it…
Let’s create a file named tornado_server.py
and put the following code in it:
from tornado.wsgi import WSGIContainer from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop from my_app import app http_server = HTTPServer(WSGIContainer(app)) http_server.listen(8000) IOLoop.instance().start...