]> git.ipfire.org Git - people/ms/webapp.git/blob - application/__init__.py
e089049362a7739c44fda1488f2b36d6aa16897c
[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 )
21
22 handlers = [
23 (r"/", MainHandler),
24 (r"/login", LoginHandler),
25 (r"/logout", LogoutHandler),
26 ] #self.get_handlers()
27
28 tornado.web.Application.__init__(self, handlers, **settings)
29
30 # # XXX This is not a nice solution but works for the moment
31 # def get_handlers(self):
32 # handlers_dir = os.path.join(BASEDIR, "pages")
33 # sys.path.append(handlers_dir)
34 # handlers = []
35 #
36 # for handler in os.listdir(handlers_dir):
37 # if not handler.endswith(".py"):
38 # continue
39 #
40 # handler = handler[:-3]
41 # handler = __import__(handler)
42 #
43 # if type(handler.handle) == type([]):
44 # handlers.extend(handler.handle)
45 # else:
46 # handlers.append(handler.handle)
47 #
48 # return handlers