Code Monkey home page Code Monkey logo

cookiecutter-tornado's Introduction

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.

  • Configurable as a Cookiecutter template
  • Basic HTML5 Boilerplate
  • (Optional) pytest
  • (Optional) tox
  • (Optional) Docker support
  • (Optional) Vagrant support
  • (Optional) Internationalization (i18n) support

Install Cookiecutter

$ pip install cookiecutter

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

$ cookiecutter https://github.com/hkage/cookiecutter-tornado

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

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

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

$ py.test

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 fabfile.py Script for other parameters and commands.

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

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

cookiecutter-tornado's People

Contributors

bwrsandman avatar hkage avatar stephendwolff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cookiecutter-tornado's Issues

Add Docker support

It would be nice to have a Docker support, in addition to the Vagrant support.

jinja error

Got the following error (Ubuntu 20.04 LTS):
$ cookiecutter https://github.com/hkage/cookiecutter-tornado
author_name [Your name]: My Name
email [Your e-mail]: [email protected]
project_name [project_name]:
repo_name [project_name]:
package_name [project_name]:
github_username [yourname]:
description [A short description of the project]:
version [0.1.0]:
python_versions [3.5,3.6,3.7,3.8]:
Select use_pytest:
1 - Yes
2 - No
Choose from 1, 2 [1]:
Select use_tox:
1 - Yes
2 - No
Choose from 1, 2 [1]:
Select use_docker:
1 - Yes
2 - No
Choose from 1, 2 [1]:
Select use_vagrant:
1 - Yes
2 - No
Choose from 1, 2 [1]:
Select use_bumpversion:
1 - Yes
2 - No
Choose from 1, 2 [1]:
Select use_i18n:
1 - Yes
2 - No
Choose from 1, 2 [1]:
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]:

And got the error:

Traceback (most recent call last):
  File "/home/welcome/.local/bin/cookiecutter", line 8, in <module>
    sys.exit(main())
  File "/home/welcome/.local/lib/python3.8/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/home/welcome/.local/lib/python3.8/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/home/welcome/.local/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/welcome/.local/lib/python3.8/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/home/welcome/.local/lib/python3.8/site-packages/cookiecutter/cli.py", line 140, in main
    cookiecutter(
  File "/home/welcome/.local/lib/python3.8/site-packages/cookiecutter/main.py", line 101, in cookiecutter
    result = generate_files(
  File "/home/welcome/.local/lib/python3.8/site-packages/cookiecutter/generate.py", line 352, in generate_files
    generate_file(
  File "/home/welcome/.local/lib/python3.8/site-packages/cookiecutter/generate.py", line 169, in generate_file
    tmpl = env.get_template(infile_fwd_slashes)
  File "/home/welcome/.local/lib/python3.8/site-packages/jinja2/environment.py", line 997, in get_template
    return self._load_template(name, globals)
  File "/home/welcome/.local/lib/python3.8/site-packages/jinja2/environment.py", line 958, in _load_template
    template = self.loader.load(self, name, self.make_globals(globals))
  File "/home/welcome/.local/lib/python3.8/site-packages/jinja2/loaders.py", line 137, in load
    code = environment.compile(source, name, filename)
  File "/home/welcome/.local/lib/python3.8/site-packages/jinja2/environment.py", line 757, in compile
    self.handle_exception(source=source_hint)
  File "/home/welcome/.local/lib/python3.8/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "./setup.py", line 130, in template
jinja2.exceptions.TemplateSyntaxError: Unexpected end of template. Jinja was looking for the following tags: 'elif' or 'else' or 'endif'. The innermost block that needs to be closed is 'if'.
  File "./setup.py", line 130
    {%- endif %}
 

I think the problem is here:
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.