-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
45 lines (39 loc) · 1.62 KB
/
Copy pathmain.py
File metadata and controls
45 lines (39 loc) · 1.62 KB
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
import tornado.web
import tornado.websocket
import tornado.httpserver
import tornado.ioloop
from pymongo import MongoClient
from handlers.chat import WebSocketHandler,chatPageHandler
from handlers.index import IndexHandler
from handlers.AddFriend import AddFriendHandler
from handlers.removeFriend import RemoveFriendHandler
from handlers.leaveGroup import LeaveGroupHandler
from handlers.joinGroup import JoinGroupHandler
from handlers.createGroup import CreateGroupHandler
# ////////////////////////////////////////////////////////////////////////////////
#-----------------------------------------------------------------------------------
class MainPageHandler(tornado.web.RequestHandler):
def get(self):
self.render("templates/MainPage.html",test="")
def post(self):
pass
# ////////////////////////////////////////////////////////////////////////////////
class Application(tornado.web.Application):
def __init__(self):
handlers = [
(r'/chat', chatPageHandler),
(r'/ws', WebSocketHandler),
(r"/MainPage", MainPageHandler),
(r"/index", IndexHandler),
(r"/addfriend",AddFriendHandler),
(r"/removefriend",RemoveFriendHandler),
(r"/leavegroup",LeaveGroupHandler),
(r"/joingroup",JoinGroupHandler),
(r"/createGroup",CreateGroupHandler)
]
tornado.web.Application.__init__(self, handlers, static_path='static',debug=True)
if __name__ == '__main__':
ws_app = Application()
server = tornado.httpserver.HTTPServer(ws_app)
server.listen(8080)
tornado.ioloop.IOLoop.instance().start()