-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
44 lines (34 loc) · 1.17 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
# coding:utf-8
import os
import redis
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.web import Application
import settings
from handlers import *
class MyApplication(Application):
def __init__(self):
handlers = [
(r"/", IndexHandler),
(r"/login", LoginHandler),
(r"/chat", ChatHandler),
(r"/update", MainSockHandler),
(r"/pip", PipHandler),
]
config = dict(
template_path=os.path.join(os.path.dirname(__file__), settings.TEMPLATE_ROOT),
static_path=os.path.join(os.path.dirname(__file__), settings.STATIC_ROOT),
xsrf_cookies=True,
login_url="/login",
cookie_secret="__E72013ADSDWIJODIE@(!)E@$*(5A1F2957AFD8EC0E7B51275EA7__",
autoescape=None,
debug=settings.DEBUG
)
Application.__init__(self, handlers, **config)
self.redis = redis.Redis(**settings.REDIS_CONF)
def run():
http_server = HTTPServer(MyApplication())
http_server.listen(port=settings.PORT, address=settings.HOST)
IOLoop.instance().start()
if __name__ == '__main__':
run()