Installing Tornado

This article illustrates how to install and test Tornado a scalable, non-blocking web server and web application framework useful to write web application written in Python.

"Because it is non-blocking and uses epoll or kqueue, it can handle thousands of simultaneous standing connections, which means the framework is ideal for real-time web services".

Installation steps

To install Tornado just type:

~# apt-get update
~# apt-get install python-tornado
...

Run your first web server

This is the basic example to build a simple web server which serves static html file.

Run it by typing:

~/playground/python/tornado# python basic.py

Open a browser on your PC and take a look to the Tornado web page using this URL:

Let's try now to access the default web pages available on /var/www with our new small web server .

Stop basic.py by typing ctrl-c and change this line:

(r"/(.*)", tornado.web.StaticFileHandler, {"path": ".","default_filename": "index.html"})

in:

(r"/(.*)", tornado.web.StaticFileHandler, {"path": "/var/www","default_filename": "index.html"})

In this way we have changed the default path. Start again the web server and reload the web page on your browser.

Related links

Sergio Tanzilli
Systems designer, webmaster of www.acmesystems.it and founder of Acme Systems srl

Personal email: tanzilli@acmesystems.it
Web pages: https://www.acmesystems.it --- https://www.acmestudio.it
Github repositories: https://github.com/tanzilli --- https://github.com/acmesystems
Telegram group dedicated to the Acme Systems boards: https://t.me/acmesystemssrl