]> git.ipfire.org Git - people/ms/webapp.git/blob - application/__init__.py
Enable debugging mode.
[people/ms/webapp.git] / application / __init__.py
1 #!/usr/bin/python
2
3 import os
4 import sys
5 import tornado.web
6
7 BASEDIR = os.path.join(os.path.dirname(__file__), "..")
8
9 from auth import LoginHandler, LogoutHandler
10 from handlers import MainHandler
11
12 class Application(tornado.web.Application):
13 def __init__(self):
14 settings = dict(
15 template_path = os.path.join(BASEDIR, "templates"),
16 static_path = os.path.join(BASEDIR, "static"),
17 xsrf_cookies = True,
18 cookie_secret = "123456789",
19 login_url = "/login",
20 debug = True,
21 )
22
23 handlers = [
24 (r"/", MainHandler),
25 (r"/login", LoginHandler),
26 (r"/logout", LogoutHandler),
27 ] #self.get_handlers()
28
29 tornado.web.Application.__init__(self, handlers, **settings)
30
31 # # XXX This is not a nice solution but works for the moment
32 # def get_handlers(self):
33 # handlers_dir = os.path.join(BASEDIR, "pages")
34 # sys.path.append(handlers_dir)
35 # handlers = []
36 #
37 # for handler in os.listdir(handlers_dir):
38 # if not handler.endswith(".py"):
39 # continue
40 #
41 # handler = handler[:-3]
42 # handler = __import__(handler)
43 #
44 # if type(handler.handle) == type([]):
45 # handlers.extend(handler.handle)
46 # else:
47 # handlers.append(handler.handle)
48 #
49 # return handlers