52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
# 引入文件夹中的文件
|
||
import sys
|
||
sys.path.append('./lib')
|
||
# 引入处理函数
|
||
from allFunction import manageLogin, manageScheduleUpload, manageScheduleGet, manageSubmitVerificationCode
|
||
# 引入flask
|
||
from flask import Flask, request, session, redirect
|
||
# 初始化app
|
||
app = Flask(__name__)
|
||
|
||
# 引入跨域访问处理模块
|
||
from flask_cors import CORS
|
||
# 取消跨域访问限制,方便本地测试 注册CORS, "/*" 允许访问所有api
|
||
CORS(app, resources=r'/*')
|
||
|
||
# 测试用根路由
|
||
@app.route('/api/')
|
||
def sayHello():
|
||
return 'Hello! Glad to serve you.'
|
||
|
||
# 登录接口,前端提供cid和pwd,包装在data里边然后md5校验也就是data:{cid,pwd,sign}
|
||
@app.route('/api/login',methods=['POST'])
|
||
def login():
|
||
res = manageLogin(request)
|
||
return res
|
||
|
||
@app.route('/api/submitVC', methods=['POST'])
|
||
def submitVC():
|
||
res = manageSubmitVerificationCode(request)
|
||
return res
|
||
|
||
# 更新课表游戏排名信息
|
||
@app.route('/api/game/schedule/upload',methods=['POST'])
|
||
def schedule_upload():
|
||
res = manageScheduleUpload(request)
|
||
return res
|
||
|
||
# 获取课表游戏排名信息
|
||
@app.route('/api/game/schedule/get',methods=['POST'])
|
||
def schedule_get():
|
||
res = manageScheduleGet(request)
|
||
return res
|
||
|
||
# 访问拦截器转发到根路由
|
||
@app.errorhandler(404)
|
||
def miss(e):
|
||
return redirect('/api')
|
||
|
||
# 本地运行启动
|
||
if __name__ == '__main__':
|
||
app.run(host="0.0.0.0", debug=True, port="7980")
|