Skip to content

Multiple Handlers #2

@mybigman

Description

@mybigman

Nice little routes decorator you have there. I've just started playing around with python again and using tornado web framework.

Everything works, however just not sure if this the best approach using your route decorator with multiple handlers?

Thanks

# handlers/__init__.py
from handlers.base import route
from handlers import base, home, summary

routes = route.get_routes()
# handlers/base.py
from vendor.router import route
from tornado.web import RequestHandler

class BaseHandler(RequestHandler):
    pass
# handlers/home.py
from handlers.base import route, BaseHandler

@route('/', name='home')
class HomeHandler(BaseHandler):
    def get(self):
        self.write({'home': {}})
# handlers/summary.py
from handlers.base import route, BaseHandler

@route('/summary', name='summary',
class SummaryHandler(BaseHandler):
    def get(self):
        self.write({'summary': {})
# app.py
from handlers import route

print(route.get_routes())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions