Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Delicate Tornado Route Decorator.

Project description

Usage:

```python
import tornado.ioloop
import tornado.web

from toroute import route

@route('/')
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")

@route('/login', name='login')
class LoginHandler(tornado.web.RequestHandler):
def get(self, *args, **kwargs):
self.write('login')

# group by `/blog`, e.g.: blog app
@route('/list', name='blog_list', kwargs={'data': 'hello'}, group='/blog')
class BlogListHandler(tornado.web.RequestHandler):
def initialize(self, **kwargs):
self.data = kwargs.get('data', None)

def get(self, *args, **kwargs):
self.write(self.data)

@route('/post', name='blog_post', group='/blog')
class BlogPostHandler(tornado.web.RequestHandler):
def get(self, *args, **kwargs):
print('post complete! redirect:%s' % route.url_for('blog_list'))
self.redirect(route.url_for('blog_list'))

@route(r'/view/(?P<pid>\d+)/detail', name='blog_view', group='/blog')
class BlogViewHandler(tornado.web.RequestHandler):
def get(self, pid, **kwargs):
msg = 'Handle Class for /blog/list is %s' \
% route.get_handler_class('/list', group='/blog').__name__
self.write(msg)

if __name__ == '__main__':

application = tornado.web.Application([
(r"/", MainHandler),
] + route.routes())
application.listen(8000)
tornado.ioloop.IOLoop.current().start()

```

Project details


Release history Release notifications

This version
History Node

0.0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
torroute-0.0.1.tar.gz (1.4 kB) Copy SHA256 hash SHA256 Source None Aug 26, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page