Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

troolee/tornado-routes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tornado routes

URL routings for tornado web server.

Usage examples:

from tornado import web
from tornado_routes import make_handlers


URL_PREFIX = ''

app = web.Application(make_handlers(URL_PREFIX,
    (r'/(robots\.txt|favicon\.ico)', web.StaticFileHandler, {"path": os.path.join(ROOT, 'static')}),
    (r'/api', include('api')),
    (r'/', include('views')),
))

api.py:

from tornado import web
from tornado_routes import route

@route('foo')
class FooHandler(web.RequestHandler):
    pass

views.py:

from tornado import web
from tornado_routes import route

@route('', name='index')
class IndexHandler(web.RequestHandler):
    pass

Your could use view names in your templates:

<a href="{{ reverse_url('index') }}">Index</a>
<a href="{{ reverse_url('api.FooHandler') }}">Foo link</a>

About

URL routings for tornado web server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages