cherry_be/coc.py
2020-04-04 08:46:45 +08:00

83 lines
2.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 引入文件夹中的文件
import sys
sys.path.append('./lib')
# 引入处理函数
from allFunction import manageLogin, managePhoto, manageAdd, manageDel, manageGet, manageDetail, manageComment, manageScheduleUpload, manageScheduleGet
# 引入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/photo/upload', methods=['PUT'], strict_slashes=False)
def upload_photo():
res = managePhoto(request)
return res
# 新增失物招领信息
@app.route('/api/laf/add',methods=['POST'])
def laf_add():
res = manageAdd(request)
return res
# 删除失物招领信息
@app.route('/api/laf/del',methods=['POST'])
def laf_del():
res = manageDel(request)
return res
# 获取全部失物招领信息
@app.route('/api/laf/get',methods=['POST'])
def laf_get():
res = manageGet()
return res
# 获取指定失物招领信息
@app.route('/api/laf/detail',methods=['POST'])
def laf_detail():
res = manageDetail(request)
return res
# 新增评论
@app.route('/api/laf/comment',methods=['POST'])
def laf_comment():
res = manageComment(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="80")