-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.py
59 lines (45 loc) · 1.31 KB
/
main.py
1
#coding=utf-8import tornado.webimport tornado.wsgiimport osimport tool.configimport loggingfrom basehandler import BaseHandlerfrom login import SignupPagefrom login import LoginPagefrom login import LogoutPagefrom home import HomePagefrom message import MessagePagefrom posts import PostPagefrom image import ImagePageclass MainHandler(BaseHandler): def get(self): self.render('front.html')class RemoveSlash(BaseHandler): def get(self,path): self.redirect(path) def post(self,path): self.redirect(path)# class DBinit(tornado.web.RequestHandler):# def get(self):# tool.config.debug_init()settings = { 'template_path' : os.path.join(os.path.dirname(__file__), 'templates'), 'cookie_secret' : tool.config.APP_Key.get('cookie_secret'), 'login_url' : '/login', 'debug' : False,}path_re = r'(?:/([a-zA-Z0-9-_]+))?'tornado_app = tornado.web.Application([ (r'(?:(.+)/)', RemoveSlash), (r'/signup', SignupPage), (r'/login', LoginPage), (r'/logout', LogoutPage), (r'/home', HomePage), (r'/message'+path_re, MessagePage), (r'/post', PostPage), (r'/img/([a-zA-Z0-9_-]+)', ImagePage), # (r'/dbinit/?', DBinit), (r'/', MainHandler),],**settings)app = tornado.wsgi.WSGIAdapter(tornado_app)