Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tamasgal/django-tornado
An example how to run django on Tornado
https://github.com/tamasgal/django-tornado
Last synced: 22 days ago
JSON representation
An example how to run django on Tornado
- Host: GitHub
- URL: https://github.com/tamasgal/django-tornado
- Owner: tamasgal
- License: mit
- Created: 2014-11-27T08:03:39.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2014-12-07T15:10:27.000Z (almost 10 years ago)
- Last Synced: 2024-10-13T19:38:37.298Z (about 1 month ago)
- Language: Python
- Size: 180 KB
- Stars: 36
- Watchers: 3
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
django-tornado
==============An example how to run Django on Tornado. Simply run `run_tornado.py` and navigate your browser to
[http://localhost:8080/hello-django](http://localhost:8080/hello-django)
or
[http://localhost:8080/hello-tornado](http://localhost:8080/hello-tornado)
to see an HTTP-response from Django, respectively Tornado.
Settings
--------You don't have to change anything to run this with your own Django project, but this line in `run_tornado.py`:
```python
os.environ['DJANGO_SETTINGS_MODULE'] = 'demosite.settings' # TODO: edit this
```The `DJANGO_SETTINGS_MODULE` should point to your `settings.py` in your Django project.
Tornado handlers
----------------To hook up Tornado handlers, use the common workflow:
```python
tornado_app = tornado.web.Application(
[
('/hello-tornado', HelloHandler),
('.*', tornado.web.FallbackHandler, dict(fallback=container)),
])
```Notice that in this example, all requests but `/hello-tornado` will be redirected to Django.
Requirements
------------You'll obviously need the django and tornado Python-modules to run this demo ;-) You can install them quickly using `pip` and the provided `requirements.txt`. I recommend creating a virtual environment for every project you're working on.
`pip install -r requirements.txt`
Or install them manually:
```
pip install django
pip install tornado
```