| 51 | |
| 52 | |
| 53 | class Application(tornado.web.Application): |
| 54 | def __init__(self, db): |
| 55 | self.db = db |
| 56 | handlers = [ |
| 57 | (r"/", HomeHandler), |
| 58 | (r"/archive", ArchiveHandler), |
| 59 | (r"/feed", FeedHandler), |
| 60 | (r"/entry/([^/]+)", EntryHandler), |
| 61 | (r"/compose", ComposeHandler), |
| 62 | (r"/auth/create", AuthCreateHandler), |
| 63 | (r"/auth/login", AuthLoginHandler), |
| 64 | (r"/auth/logout", AuthLogoutHandler), |
| 65 | ] |
| 66 | settings = dict( |
| 67 | blog_title="Tornado Blog", |
| 68 | template_path=os.path.join(os.path.dirname(__file__), "templates"), |
| 69 | static_path=os.path.join(os.path.dirname(__file__), "static"), |
| 70 | ui_modules={"Entry": EntryModule}, |
| 71 | xsrf_cookies=True, |
| 72 | cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__", |
| 73 | login_url="/auth/login", |
| 74 | debug=True, |
| 75 | ) |
| 76 | super().__init__(handlers, **settings) |
| 77 | |
| 78 | |
| 79 | class BaseHandler(tornado.web.RequestHandler): |