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".

Install Tornado on Aria, Terra or FOX boards

Download and save the file tornado-x.x.x.tar.gz on the CORE9G25 board microSD which contains the latest stable version of Tornado from the following link:

Untar the archive file:

debarm:~# tar xvzf tornado-x.x.x.tar.gz
...

Move into the new directory and install Tornado by typing:

debarm:~# cd tornado-x.x.x                                                      
debarm:~/tornado-x.x.x# python setup.py install
...

Run your first web server

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

basic.py, The web server, Position: CD://Debian/playground/python/tornado/basic.py

import tornado.ioloop
import tornado.web

application = tornado.web.Application([
	(r"/(.*)", tornado.web.StaticFileHandler, {"path": ".","default_filename": "index.html"})
])

if __name__ == "__main__":
	application.listen(8080,"0.0.0.0")
	tornado.ioloop.IOLoop.instance().start()

index.html, A very basic static html file. Position: CD://Debian/playground/python/tornado/index.html

I'm your default index page
  • A binary favicon.ico file

Run it by typing:

debarm:~/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

Documentation Terms of Use
The Acme Systems srl provides this Debian system development and user manual.
The origin of these doc came from the website: http://www.acmesystems.it
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
Creative Commons License


Market Mail : market@armdevs.com
Support Mail: support@armdevs.com Sales Phone: +86-755-29638421


CoreWind Online Chat>
Work time: 09:00-18:00
Copyright @ 2014 to 2020 - CoreWind Tech.