-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
51 lines (43 loc) · 1.38 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# coding: utf-8
import os.path
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import tornado.httpserver
import tornado.ioloop
import tornado.web
import tornado.options
import config
from controllers import user,index
from database import create_db
from helpers import getAvatar
config = config.rec()
class Application(tornado.web.Application):
def __init__(self):
handlers = [
(r"/", index.HomeHandler),
(r"/index[/]*", index.IndexHandler),
(r"/login[/]*", user.LoginHandler),
(r"/logout[/]*", user.LogoutHandler),
(r"/register[/]*", user.RegisterHandler),
]
settings = dict(
template_path = os.path.join("templates"),
static_path = os.path.join("static"),
xsrf_cookies = True,
cookie_secret = config.cookie_secret,
autoescape = None,
title = config.title,
url = config.url,
login_url = "/",
debug=True,
)
tornado.web.Application.__init__(self, handlers, **settings)
def main():
#create_db()
print("App started. Listenning on %d" % int(os.environ.get('PORT', 8888)))
tornado.options.parse_command_line()
tornado.httpserver.HTTPServer(Application()).listen(int(os.environ.get('PORT',8888)))
tornado.ioloop.IOLoop.instance().start()
if __name__ == '__main__':
main()