Skip to content
Go to file


Tornado Cookiecutter template

license build

This is my cookiecutter template to build a simple, fast and rock solid website based upon the Tornado framework. There are quite many Tornado templates out there, but I wanted to start something from scratch, that fits my needs and evolves out of years of experiences (positive and negative alike) with other Python based webframeworks like Turbogears and Django.

Of course this template is not designed for larger data structures. The main focus is on scalability, fast data access and small library dependencies.

1   Features

  • Configurable as a Cookiecutter template
  • Basic HTML5 Boilerplate
  • (Optional) pytest
  • (Optional) tox
  • (Optional) Bumpversion for updating version information
  • (Optional) Docker support
  • (Optional) Vagrant support

2   Usage

Install Cookiecutter

$ pip install cookiecutter

Initialize the project with cookiecutter and answer some questions for the newly started project:

$ cookiecutter

project_name [project_name]:
project_slug [project_name]:
author_name [Your name]:
email [Your e-mail]:
github_username [yourname]:
repo_name [tornado-project]:
description [A short description of the project]:
version [0.1.0]:
use_pytest [y]:
use_tox [y]:
use_docker [y]:
use_vagrant [y]:
use_bumpversion [y]:
max_line_length [120]:
Select open_source_license:
1 - MIT license
2 - BSD license
3 - ISC license
4 - Apache Software License 2.0
5 - GNU General Public License v3
6 - Not open source
Choose from 1, 2, 3, 4, 5, 6 [1]:

3   Template development

If you decide to contribute to this cookiecutter template, feel free to fork it and make a pull request. To start with the development of this template, you need to install some Python requirements:

[sudo] pip install poetry

After that simply let pipenv install all requirements:

$ poetry install

To activate the virtual environment, simply call:

$ poetry shell

Now you are able to run the tests for this template:

$ py.test

In addition to that you can install tox to test the template against different Python versions:

$ [sudo] pip install tox

And then run the tests with:

$ tox

4   Tornado project development

4.1   Testing

All tests will be added to the tests directory, whether you are using pytest for testing or other tools like nose- or unittests.

4.1.1   pytest

With pytest you will be able to run the tests with:

$ py.test

4.2   Running the application

To start the final application, just run the following fabric command:

$ fab devserver

This will tell Tornado to start the application with the default port 8888. If you want to use another port, just type:

$ fab devserver:port=8000

In addition to that, see the Script for other parameters and commands.

4.2.1   Vagrant

To run the server within a Vagrant VM, you need to install Vagrant 1.7.x and the Vagrant Alpine plugin:

$ vagrant plugin install vagrant-alpine

After that you can start the development server with the following command:

$ vagrant up
$ fab vagrant devserver

You can now access your application via http://localhost:8000

4.2.2   Docker

Install docker and docker compose in the latest version. Then start the tornado project with docker-compose:

$ docker-compose up

You can now access your application via http://localhost:8000

You can’t perform that action at this time.