Giter Site home page Giter Site logo

tornado-boilterplate's Introduction

Tornado Boilerplate v3.1

This is a quick boilerplate to start building apps with Tornado. It has an almost similar organization of a Django project, as most people are familar with it. This is how it looks -

.
├── server.py
├── apps
│   ├── __init__.py
│   └── main
│       ├── __init__.py
│       ├── urls.py
│       └── views.py
├── __init__.py
├── settings.py
├── static
│   └── style.css
├── templates
│   ├── base.html
│   └── home.html
└── urls.py

Settings

Settings as a dictionary, with full reference

settings = {
    # debug: If True the application runs in debug mode
    'debug': True,

    ...
}

Shell

Added shell to play with the system

(venv) ~/Works/tornado-boilerplate/project$ python shell.py
>>> import tornado.web
>>>

Apps

Added apps folder to separate logic in modules


Importing urls

Enabled importing/including urls from different apps, maintaing pattern

from tornado.web import URLSpec as url

urls = [
    url(r"/", HomeHandler),
    url(r"/static/(.*)", web.StaticFileHandler, {"path": settings.get('static_path')}),
]
# this will include patterns from urls.py inside `main` app.
urls += include(r"/main/", "apps.main.urls")

/apps/main/urls.py

from tornado.web import URLSpec as url

urls = [
    url(r"test/", TestHandler),  # This is `/main/test/`
]

Server start/stop message

Showing message when starting and stoping the server

(venv) ~/Works/tornado-boilerplate/project$ python server.py
Starting server on http://127.0.0.1:8888
^C
Stopping server.

tornado-boilterplate's People

Watchers

 avatar  avatar

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.