I create very basic and very hacky way to use many handlers in my project, i give you an example maybe it helps to your project..
mkdir handlers
write all handlers inside handlers like
handlers/user.py
import tornado.web
class RegisterHandler(tornado.web.requestHandler)
ROUTE = "/user/register"
def get(self):
...
def post(self):
class LoginHandler(tornado.web.requestHandler):
ROUTE = "/user/login"
def get(self):
...
def post(self):
....
handlers/__init__.py
import user
ROUTES = []
MODULES = [
user
]
for module in MODULES:
members = inspect.getmembers(sys.modules[module.__name__], inspect.isclass)
for cls in members:
if hasattr(cls[1], "ROUTE"):
ROUTES.append((r"%s" % (cls[1].ROUTE,), cls[1]))
and in projectname.py
import handlers
import tornado.web
class Application(tornado.web.Application):
def __init__(self):
settings = {
....
}
tornado.web.Application.__init__(self, handlers.ROUTES, **settings)
.....