-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
30 lines (26 loc) · 904 Bytes
/
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
import asyncio
import os
import tornado.web
from tornado.platform.asyncio import AsyncIOMainLoop
from handlers import MainHandler, WSGameHandler, WSChatHandler, WSOnlineHandler, LogoutHandler, ScoreHandler
app = tornado.web.Application(
[
(r'/', MainHandler),
(r'/ws/game/(?P<id>\w+)/(?P<coordinates>\S+)/(?P<nick>\S+)/', WSGameHandler),
(r'/ws/chat/(?P<id>\w+)/(?P<nick>\w+)/', WSChatHandler),
(r'/ws/online/(?P<nick>\w+)/', WSOnlineHandler),
(r'/logout/', LogoutHandler),
(r'/score/', ScoreHandler),
],
template_path=os.path.join(os.path.dirname(__file__), "templates"),
static_path=os.path.join(os.path.dirname(__file__), "static"),
xsrf_cookies=False,
debug=True
)
app.listen(8888)
AsyncIOMainLoop().install()
loop = asyncio.get_event_loop()
try:
loop.run_forever()
except KeyboardInterrupt:
print("server stopped")