-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
69 lines (63 loc) · 2.68 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import datetime
from blueprints.anadata import bp as data
from blueprints.conn import bp as conn
from blueprints.discuss import bp as discuss
from blueprints.sockjs import CCHandler, ChatRoomHandler,CanvasConnection as BoardHandler, AudioHandler, CommentHandler, checkHandler
import tornado.ioloop
import tornado.web
from tornado.web import Application, FallbackHandler
from tornado.wsgi import WSGIContainer
import sockjs.tornado
import sockjs
import config
from flask import Flask, session, g, request, redirect, render_template, url_for
from flask_sockets import Sockets
from blueprints.screen import bp as screen
from blueprints.dm import bp as dm
from blueprints.course import bp as course
from blueprints.build import bp as build
from blueprints.login import bp as login
from blueprints.logout import bp as logout
from blueprints.msg import bp as msg
from blueprints.myStream import bp as myStream
from blueprints.playchat import bp as playchat
from blueprints.regist import bp as regist
from blueprints.main import bp as main
from blueprints.stream import bp as stream
from blueprints.upload import bp as upload
from blueprints.userprofile import bp as userprofile
from blueprints.index import bp as index
from blueprints.complaint import bp as test
from blueprints.service import bp as service
from blueprints.help import bp as hhelp
from blueprints.renmark import bp as renmark
from flask_migrate import Migrate
from flask_wtf import CSRFProtect
from flask_cors import CORS
app = Flask(__name__)
CORS(app, supports_credentials=True)
app.config.from_object(config)
app.debug=True
# 视图绑定
blueprint_list = [
main, regist, login, userprofile, logout, upload, playchat,
build, myStream, stream, msg, index, course, dm, test, service,
hhelp, screen, renmark, conn, discuss, data
]
for cur_bp in blueprint_list:
app.register_blueprint(cur_bp)
if __name__ == '__main__':
IP = '127.0.0.1' if 1 else '10.70.43.81'
# app.run(host=IP, port=8000)
ChatRouter = sockjs.tornado.SockJSRouter(ChatRoomHandler, '/chatroom')
BoardRouter = sockjs.tornado.SockJSRouter(BoardHandler, '/board')
AudioRouter = sockjs.tornado.SockJSRouter(AudioHandler, '/audio')
checkRouter = sockjs.tornado.SockJSRouter(checkHandler, '/check')
commenRouter = sockjs.tornado.SockJSRouter(CommentHandler, '/comment')
ccRouter = sockjs.tornado.SockJSRouter(CCHandler, '/cc')
wsgi_app = WSGIContainer(app)
application = tornado.web.Application(
ChatRouter.urls + BoardRouter.urls + AudioRouter.urls + checkRouter.urls + commenRouter.urls + ccRouter.urls + [(r'.*', FallbackHandler, dict(fallback=wsgi_app))]
)
application.listen(8000, address=IP)
tornado.ioloop.IOLoop.instance().start()