https://github.com/cfhamlet/os-tornado
A framework to simplify tornado daemon development and project orgnization.
https://github.com/cfhamlet/os-tornado
tornado-framework
Last synced: 4 months ago
JSON representation
A framework to simplify tornado daemon development and project orgnization.
- Host: GitHub
- URL: https://github.com/cfhamlet/os-tornado
- Owner: cfhamlet
- License: mit
- Created: 2017-06-22T03:45:33.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-01-14T07:19:40.000Z (over 7 years ago)
- Last Synced: 2025-10-27T07:54:09.463Z (8 months ago)
- Topics: tornado-framework
- Language: Python
- Homepage:
- Size: 60.5 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
==========
os-tornado
==========
.. image:: https://travis-ci.org/cfhamlet/os-tornado.svg?branch=master
:target: https://travis-ci.org/cfhamlet/os-tornado
.. image:: https://codecov.io/gh/cfhamlet/os-tornado/branch/master/graph/badge.svg
:target: https://codecov.io/gh/cfhamlet/os-tornado
.. image:: https://img.shields.io/pypi/pyversions/os-tornado.svg
:alt: PyPI - Python Version
:target: https://pypi.python.org/pypi/os-tornado
.. image:: https://img.shields.io/pypi/v/os-tornado.svg
:alt: PyPI
:target: https://pypi.python.org/pypi/os-tornado
A framework to organize tornado project and simplify development.
.. note::
This project will no longer maintenance. You can use `os-sanic `_ as substitute which has better performance and more flexible.
Install
-------
``pip install os-tornado``
Usage
------
* Create project
``os-tornado startproject new_project``
Will create a project structure::
new_project/
├── app
│ ├── extensions
│ │ ├── example_extension.py
│ │ ├── __init__.py
│ ├── request_handlers
│ │ ├── example_handler.py
│ │ ├── __init__.py
│ ├── __init__.py
│ ├── settings.py
└── manager.py
* Write your extensions and request handlers
* Extension
You can implement ``setup``, ``run``, ``cleanup`` as your need.
* Request handler
See `tornado.web — RequestHandler and Application classes `_
You can get extension inside request handler:
``self.application.manager.get_extenion(extension_name)``
* Configure settings (app/settings.py)
* You can set tornado inner app settings and server settings with specified PREFIX:
`TORNADO_APP_SETTINGS_ `_
`TORNADO_SERVER_SETTINGS_ `_
example:
``TORNADO_APP_SETTINGS_DEBUG = True``
* Run server
``python manager.py runserver``
Advanced Usage
--------------
* ``os_tornado.decorators.jsonify``
jsonify returned dict and raised HTTPError
example:
.. code-block:: python
@jsonify
class ExampleHandler(RequestHandler):
def get(self, *args, **kwargs):
return {'status':'ok'}
def post(self, *args, **kwargs):
raise HTTPHandler(405)
Unit Tests
----------
``$ tox``
License
--------
MIT licensed.