diff --git a/README.md b/README.md index ab78939..0e5b105 100644 Binary files a/README.md and b/README.md differ diff --git a/app-dm/.gitignore b/app-dm/.gitignore index 4d29575..fd9e0b4 100644 --- a/app-dm/.gitignore +++ b/app-dm/.gitignore @@ -11,6 +11,8 @@ # production /build + + # misc .DS_Store .env.local diff --git a/app-dm/src/TeacherPages/SendTest/SendTest.jsx b/app-dm/src/TeacherPages/SendTest/SendTest.jsx index 87b5c69..e4c5d37 100644 --- a/app-dm/src/TeacherPages/SendTest/SendTest.jsx +++ b/app-dm/src/TeacherPages/SendTest/SendTest.jsx @@ -14,7 +14,7 @@ function SendTest(){ const subject = async ()=>{ try{ - const subject_src=await axios.post('http://127.0.0.1:5000/teacher/return_question',{ + const subject_src=await axios.post('/api/teacher/return_question',{ teacher_ID}) SetChoiceQuestion(subject_src.data['选择']) SetCompletion(subject_src.data['填空']) @@ -41,7 +41,7 @@ function SendTest(){ const click_1= async()=>{ try { - const select_class_src = await axios.post('http://127.0.0.1:5000/teacher/select_class', { + const select_class_src = await axios.post('/api/teacher/select_class', { teacher_ID }); background.style.display='block' @@ -119,7 +119,7 @@ function SendTest(){ // 发布按钮 const release= async()=>{ try{ - const release_src=await axios.post('http://127.0.0.1:5000/teacher/accept_test',{ + const release_src=await axios.post('/api/teacher/accept_test',{ teacher_ID, ChoiceQuestionSet,//选择题 CompletionQuestionSet,//填空题 diff --git a/app-dm/src/TeacherPages/SendTrain/SendTrain.jsx b/app-dm/src/TeacherPages/SendTrain/SendTrain.jsx index 5e29609..734c247 100644 --- a/app-dm/src/TeacherPages/SendTrain/SendTrain.jsx +++ b/app-dm/src/TeacherPages/SendTrain/SendTrain.jsx @@ -20,7 +20,7 @@ function SendTrain(){ const Train_question_func=async()=>{ try{ - const Train_question_src=await axios.post('http://127.0.0.1:5000/teacher/fetch_train_question') + const Train_question_src=await axios.post('/api/teacher/fetch_train_question') SetTrainquestion(Train_question_src.data) }catch{ alert('Train_question_func出错') @@ -29,7 +29,7 @@ function SendTrain(){ const SeleactClass= async()=>{ try { - const select_class_src = await axios.post('http://127.0.0.1:5000/teacher/select_class', { + const select_class_src = await axios.post('/api/teacher/select_class', { teacher_ID }); SetClassData(select_class_src.data['Class']); @@ -66,7 +66,7 @@ function SendTrain(){ //发送题目 const SendTrainTest=async ()=>{ try{ - const SendTrainSrc=await axios.post('http://127.0.0.1:5000/teacher/SendTrainTest',{ + const SendTrainSrc=await axios.post('/api/teacher/SendTrainTest',{ TrainChoice, TrainCompletion, TrainJudge, diff --git a/app-dm/src/TeacherPages/TeacherPage.jsx b/app-dm/src/TeacherPages/TeacherPage.jsx index ca28355..0040872 100644 --- a/app-dm/src/TeacherPages/TeacherPage.jsx +++ b/app-dm/src/TeacherPages/TeacherPage.jsx @@ -35,7 +35,7 @@ function TeacherPage() { //查找班级 const select_class = async () => { try { - const select_class_src = await axios.post('http://127.0.0.1:5000/teacher/select_class', { + const select_class_src = await axios.post('/api/teacher/select_class', { teacher_ID }); setClassData(select_class_src.data['Class']); diff --git a/app-dm/src/TeacherPages/classlistpages/classId.jsx b/app-dm/src/TeacherPages/classlistpages/classId.jsx index ad76dbb..0e43f84 100644 --- a/app-dm/src/TeacherPages/classlistpages/classId.jsx +++ b/app-dm/src/TeacherPages/classlistpages/classId.jsx @@ -14,7 +14,7 @@ function TeacherPage() { const [classdata,setClassData]=useState([]) const class_succeed = async () => { try{ - const class_scr=await axios.post('http://127.0.0.1:5000/teacher/find_student',{key}) + const class_scr=await axios.post('/api/teacher/find_student',{key}) const class_data=class_scr.data setClassData(class_data[1]) setisclick(true) diff --git a/app-dm/src/TeacherPages/teachermanagetest/ManageTest.jsx b/app-dm/src/TeacherPages/teachermanagetest/ManageTest.jsx index 19ae95a..517c3b9 100644 --- a/app-dm/src/TeacherPages/teachermanagetest/ManageTest.jsx +++ b/app-dm/src/TeacherPages/teachermanagetest/ManageTest.jsx @@ -18,7 +18,7 @@ function TeacherPage() { const select_class = async () => { try { - const select_class_src = await axios.post('http://127.0.0.1:5000/teacher/select_class',{ + const select_class_src = await axios.post('/api/teacher/select_class',{ teacher_ID }); setClassData(select_class_src.data['Class']); @@ -45,7 +45,7 @@ function TeacherPage() { useEffect(()=>{ const change_class = async () => { try { - const change_class_src = await axios.post('http://127.0.0.1:5000/teacher/change_class',{ + const change_class_src = await axios.post('/api/teacher/change_class',{ teacher_ID, selectedValue, testID @@ -74,7 +74,7 @@ function TeacherPage() { const click_detailed= async()=>{ //获取详细信息 try{ - const detaileddata_src=await axios.post('http://127.0.0.1:5000/teacher/detaileddata',{ + const detaileddata_src=await axios.post('/api/teacher/detaileddata',{ testID, selectedValue, teacher_ID diff --git a/app-dm/src/pages/Home/Home.jsx b/app-dm/src/pages/Home/Home.jsx index 73b66e7..40e4815 100644 --- a/app-dm/src/pages/Home/Home.jsx +++ b/app-dm/src/pages/Home/Home.jsx @@ -39,7 +39,7 @@ function Home(){ const student_succeed_func = async () => { const student_ID=localStorage.getItem('islogin') try{ - const student_succeed_src=await axios.post('http://127.0.0.1:5000/student',{ + const student_succeed_src=await axios.post('/api/student',{ student_ID }); //提取课程 diff --git a/app-dm/src/pages/Home/img/班级.jpg b/app-dm/src/pages/Home/img/班级.jpg new file mode 100644 index 0000000..1e7dde0 Binary files /dev/null and b/app-dm/src/pages/Home/img/班级.jpg differ diff --git a/app-dm/src/pages/Home/img/问题.jpg b/app-dm/src/pages/Home/img/问题.jpg new file mode 100644 index 0000000..d39a339 Binary files /dev/null and b/app-dm/src/pages/Home/img/问题.jpg differ diff --git a/app-dm/src/pages/ListPages/Subject/Exam.jsx b/app-dm/src/pages/ListPages/Subject/Exam.jsx index 3b7673e..dcf600b 100644 --- a/app-dm/src/pages/ListPages/Subject/Exam.jsx +++ b/app-dm/src/pages/ListPages/Subject/Exam.jsx @@ -19,7 +19,7 @@ function Exam(){ const [testdata,settestdata]=useState('') const test_func= async()=>{ try{ - const test_src= await axios.post('http://127.0.0.1:5000/student/get_test',{student_ID}) + const test_src= await axios.post('/api/student/get_test',{student_ID}) const test_data=test_src.data['data'] settestdata(test_data) }catch(error){ @@ -132,7 +132,7 @@ function Exam(){ if(isMounted){ const score_func=async()=>{ try{ - const score_entry_src=await axios.post('http://127.0.0.1:5000/student/score_entry',{ + const score_entry_src=await axios.post('/api/student/score_entry',{ student_ID, score, examId diff --git a/app-dm/src/pages/ListPages/Subject/SubjectPage.jsx b/app-dm/src/pages/ListPages/Subject/SubjectPage.jsx index 8b2e40e..98ca920 100644 --- a/app-dm/src/pages/ListPages/Subject/SubjectPage.jsx +++ b/app-dm/src/pages/ListPages/Subject/SubjectPage.jsx @@ -17,7 +17,7 @@ function SubjectPage(){ //根据学生ID获取他的考试卷子 const test=async()=>{ try{ - const test_src= await axios.post('http://127.0.0.1:5000/student/get_test',{student_ID}) + const test_src= await axios.post('/api/student/get_test',{student_ID}) settestdata(test_src.data['data']) }catch(error){ alert(error) @@ -32,7 +32,7 @@ function SubjectPage(){ //获取他已经做过的试卷 const end_test=async()=>{ try{ - const end_test_src=await axios.post('http://127.0.0.1:5000/student/get_end_student',{student_ID}) + const end_test_src=await axios.post('/api/student/get_end_student',{student_ID}) const obj=end_test_src.data['result'] setEndTestList(obj) }catch(error){ @@ -67,7 +67,7 @@ function SubjectPage(){ const find_result_func=async()=>{ try{ - const find_result=await axios.post('http://127.0.0.1:5000/student/fetch_result',{ + const find_result=await axios.post('/api/student/fetch_result',{ student_ID }) setresult(find_result.data['result']) diff --git a/app-dm/src/pages/ListPages/img/主页.jpg b/app-dm/src/pages/ListPages/img/主页.jpg new file mode 100644 index 0000000..ea393a6 Binary files /dev/null and b/app-dm/src/pages/ListPages/img/主页.jpg differ diff --git a/app-dm/src/pages/ListPages/img/班级.jpg b/app-dm/src/pages/ListPages/img/班级.jpg new file mode 100644 index 0000000..1e7dde0 Binary files /dev/null and b/app-dm/src/pages/ListPages/img/班级.jpg differ diff --git a/app-dm/src/pages/ListPages/img/箭头1.jpg b/app-dm/src/pages/ListPages/img/箭头1.jpg new file mode 100644 index 0000000..f760d6a Binary files /dev/null and b/app-dm/src/pages/ListPages/img/箭头1.jpg differ diff --git a/app-dm/src/pages/ListPages/img/设置.jpg b/app-dm/src/pages/ListPages/img/设置.jpg new file mode 100644 index 0000000..e262270 Binary files /dev/null and b/app-dm/src/pages/ListPages/img/设置.jpg differ diff --git a/app-dm/src/pages/ListPages/img/问题.jpg b/app-dm/src/pages/ListPages/img/问题.jpg new file mode 100644 index 0000000..d39a339 Binary files /dev/null and b/app-dm/src/pages/ListPages/img/问题.jpg differ diff --git a/app-dm/src/pages/ListPages/img/题目.jpg b/app-dm/src/pages/ListPages/img/题目.jpg new file mode 100644 index 0000000..29a750d Binary files /dev/null and b/app-dm/src/pages/ListPages/img/题目.jpg differ diff --git a/app-dm/src/pages/SighUp/SignUpForm.jsx b/app-dm/src/pages/SighUp/SignUpForm.jsx index 41d67c8..a822c17 100644 --- a/app-dm/src/pages/SighUp/SignUpForm.jsx +++ b/app-dm/src/pages/SighUp/SignUpForm.jsx @@ -62,7 +62,7 @@ import axios from 'axios'; alert('学号错误') return } - const register_func=await axios.post('http://127.0.0.1:5000/register',{ + const register_func=await axios.post('/api/register',{ name, ID, password, diff --git a/app-dm/src/pages/SignIn/SignInPage.jsx b/app-dm/src/pages/SignIn/SignInPage.jsx index abf85b2..ec1594b 100644 --- a/app-dm/src/pages/SignIn/SignInPage.jsx +++ b/app-dm/src/pages/SignIn/SignInPage.jsx @@ -12,7 +12,7 @@ function SignInPage(){ const login = async () => { try { - const login_data = await axios.post('http://127.0.0.1:5000/login', { + const login_data = await axios.post('/api/login', { ID, password }); diff --git a/app-dm/src/setupProxy.js b/app-dm/src/setupProxy.js new file mode 100644 index 0000000..57c0f6f --- /dev/null +++ b/app-dm/src/setupProxy.js @@ -0,0 +1,4 @@ +const proxy=require("http-proxy-middleware") +module.exports=function(app){ + app.use(proxy(['/api'],{target:"http://localhost:5000"})) +} \ No newline at end of file diff --git a/build.sh b/build.sh index cd973f0..029e22f 100644 --- a/build.sh +++ b/build.sh @@ -1,3 +1,51 @@ -docker compose build -docker compose build build-dmpython -docker compose build build-frontend \ No newline at end of file +#!/bin/bash + +# 获取当前文件夹名字 +current_dir=$(basename "$PWD") + +# 确保有稳定的网络环境 +ensure_network() { + read -p "请确保有稳定的网络环境[Y/N] " confirm + if [[ ! $confirm =~ ^[yY]([eE][sS])?$ ]]; then + exit 1 + fi +} + +# 打包镜像 +build_image() { + local service_name=$1 + echo "打包${service_name}镜像" + docker compose build "$service_name" +} + +# 推送镜像 +push_image() { + read -p "是否要推送到《达梦启元云原生大数据平台》? [Y/N] " confirm + if [[ $confirm =~ ^[yY]([eE][sS])?$ ]]; then + echo "tag" + docker tag "${current_dir}-flask-app" 36.138.114.105:31000/cnsof50011836/flask-app + echo "pushing" + docker push 36.138.114.105:31000/cnsof50011836/flask-app + echo "pushed" + else + echo "用户选择不推送镜像" + fi +} + +# 主流程 +main() { + echo "打包中" + ensure_network + + build_image base + build_image base-dm + build_image build-dmpython + build_image build-frontend + build_image flask-app + + push_image + + echo "脚本结束" +} + +main \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index a00f43d..7b095cd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,14 @@ services: + base: + build: ./docker/base + image: base + base-dm: build: ./docker/base-dm image: base-dm + depends_on: + - base build-dmpython: build: ./docker/build-dmpython @@ -28,20 +34,3 @@ services: retries: 3 command: gunicorn -w 3 -t 60 -b 0.0.0.0:8000 app:app - nginx-proxy: - build: ./docker/nginx - restart: always - volumes: - - ./docker/nginx/default.conf:/tmp/default.conf - environment: - - FLASK_SERVER_ADDR=flask-app:8000 - ports: - - "80:80" - depends_on: - - flask-app - healthcheck: - test: ["CMD-SHELL", "curl --silent --fail localhost:80/health-check || exit 1"] - interval: 10s - timeout: 10s - retries: 3 - command: /app/start.sh diff --git a/docker/base-dm/Dockerfile b/docker/base-dm/Dockerfile index ad460c9..1d30f8f 100644 --- a/docker/base-dm/Dockerfile +++ b/docker/base-dm/Dockerfile @@ -1,35 +1,16 @@ -FROM ubuntu -# apt安装时,防止卡死在交互界面 -ENV DEBIAN_FRONTEND=noninteractive -ENV LANG=zh_CN.UTF-8 -ENV LC_ALL=zh_CN.UTF-8 -# 基础软件安装 -RUN sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list \ -&& apt-get -y update && apt-get -y upgrade \ -&& apt-get install -y python3.10-venv libssl-dev sudo vim python3-pip ssh wget unzip p7zip* language-pack-zh-hans language-selector-common locales locales-all \ -# 设置中文环境 -&& apt install -y $(check-language-support) \ -&& echo "zh_CN.UTF-8 UTF-8" >> /etc/locale.gen \ -&& sudo /usr/sbin/update-locale LANG=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8 \ -&& locale-gen \ +FROM base # 添加用户 -&& useradd -m -s /bin/bash dmdba \ +RUN useradd -m -s /bin/bash dmdba \ # 修改用户密码 -&& echo "dmdba:123456" | chpasswd \ -&& pip config set global.index-url https://mirrors.bfsu.edu.cn/pypi/web/simple \ -&& echo "**** clean up ****" && \ -apt-get clean && \ -rm -rf \ - /config/* \ - /tmp/* \ - /var/lib/apt/lists/* \ - /var/tmp/* -# 传入安装包并解压 +&& echo "dmdba:123456" | chpasswd WORKDIR /home/dmdba + +# 传入安装包并解压 RUN wget https://download.dameng.com/eco/adapter/DM8/202405/dm8_20240408_x86_rh7_64_ent_8.1.3.140.zip RUN unzip dm8_20240408_x86_rh7_64_ent_8.1.3.140.zip \ && chown -R dmdba:dmdba /home/dmdba \ && rm -f dm8_20240408_x86_rh7_64_ent_8.1.3.140.zip \ && 7z x dm8_20240408_x86_rh7_64.iso \ && rm -f dm8_20240408_x86_rh7_64.iso \ -&& chmod +x DMInstall.bin \ No newline at end of file +&& chmod +x DMInstall.bin +USER dmdba \ No newline at end of file diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile new file mode 100644 index 0000000..f73ec32 --- /dev/null +++ b/docker/base/Dockerfile @@ -0,0 +1,22 @@ +FROM ubuntu +# apt安装时,防止卡死在交互界面 +ENV DEBIAN_FRONTEND=noninteractive +ENV LANG=zh_CN.UTF-8 +ENV LC_ALL=zh_CN.UTF-8 +# 基础软件安装 +RUN sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list \ +&& apt-get -y update && apt-get -y upgrade \ +&& apt-get install -y python3.10-venv libssl-dev sudo vim python3-pip ssh wget unzip p7zip* language-pack-zh-hans language-selector-common locales locales-all \ +# 设置中文环境 +&& apt install -y $(check-language-support) \ +&& echo "zh_CN.UTF-8 UTF-8" >> /etc/locale.gen \ +&& sudo /usr/sbin/update-locale LANG=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8 \ +&& locale-gen \ +&& pip config set global.index-url https://mirrors.bfsu.edu.cn/pypi/web/simple \ +&& echo "**** clean up ****" && \ +apt-get clean && \ +rm -rf \ + /config/* \ + /tmp/* \ + /var/lib/apt/lists/* \ + /var/tmp/* diff --git a/docker/build-dmpython/auto_install.xml b/docker/build-dmpython/auto_install.xml index 7a68ff0..e6e6523 100644 --- a/docker/build-dmpython/auto_install.xml +++ b/docker/build-dmpython/auto_install.xml @@ -115,7 +115,7 @@ - Y + N N diff --git a/python/Dockerfile b/python/Dockerfile index ac80947..4d0eac3 100644 --- a/python/Dockerfile +++ b/python/Dockerfile @@ -1,13 +1,13 @@ -FROM base-dm +FROM base # 升级pip RUN pip install --upgrade pip # 创建一个用户运行flask -RUN adduser flask -RUN chown -R flask:flask /home/flask -RUN mkdir -p /var/log/flask-app && touch /var/log/flask-app/flask-app.err.log && touch /var/log/flask-app/flask-app.out.log -RUN chown -R flask:flask /var/log/flask-app +RUN adduser flask && \ +chown -R flask:flask /home/flask && \ +mkdir -p /var/log/flask-app && touch /var/log/flask-app/flask-app.err.log && touch /var/log/flask-app/flask-app.out.log && \ +chown -R flask:flask /var/log/flask-app WORKDIR /home/flask USER flask @@ -16,18 +16,18 @@ COPY --chown=flask:flask . . # venv ENV VIRTUAL_ENV=/home/flask/venv +ENV PATH="$VIRTUAL_ENV/bin:$PATH" # 安装包 -RUN python3 -m venv "$VIRTUAL_ENV" -ENV PATH="$VIRTUAL_ENV/bin:$PATH" -RUN export FLASK_APP=main.py COPY --from=build-dmpython --chown=flask:flask /home/dmdba/build_artifacts/dmPython-2.5.5-cp310-cp310-linux_x86_64.whl . +RUN python3 -m venv "$VIRTUAL_ENV" && \ +export FLASK_APP=app.py && \ +pip3 install dmPython-2.5.5-cp310-cp310-linux_x86_64.whl && rm dmPython-2.5.5-cp310-cp310-linux_x86_64.whl && \ +MAKEFLAGS="-j$(nproc)" pip install -r requirements.txt COPY --from=build-dmpython /home/dmdba/build_artifacts/libdmdpi.so /usr/lib/ COPY --from=build-frontend /usr/src/app/build/ /home/flask/public/ -RUN pip3 install dmPython-2.5.5-cp310-cp310-linux_x86_64.whl && rm dmPython-2.5.5-cp310-cp310-linux_x86_64.whl -RUN MAKEFLAGS="-j$(nproc)" pip install -r requirements.txt -USER root + # 暴露端口 EXPOSE 5000 -CMD ["python", "main.py"] \ No newline at end of file +CMD ["gunicorn", "-w", "3", "-t", "60", "-b", "0.0.0.0:8000", "app:app"] \ No newline at end of file diff --git a/python/app.py b/python/app.py index db471ab..15aa22e 100644 --- a/python/app.py +++ b/python/app.py @@ -8,7 +8,7 @@ CORS(app, resources={r"/*": {"origins": "*"}}) app.config['SECRET_KEY'] = '350625' -@app.route('/student', methods=['POST']) # 检测历史是否登录过,登录则直接进入index,反之则进去login界面 +@app.route('/api/student', methods=['POST']) # 检测历史是否登录过,登录则直接进入index,反之则进去login界面 def student(): # 判断是否已经登录 ID_data = request.json ID = ID_data['student_ID'] @@ -17,7 +17,7 @@ def student(): # 判断是否已经登录 return jsonify({'student_succeed': student_succeed, 'student_lesson': student_lesson}) -@app.route('/login', methods=['POST']) # 登录功能 +@app.route('/api/login', methods=['POST']) # 登录功能 def login(): login_data = request.json # 获取前端发送过来的数据 ID = login_data['ID'] # 解析数据 @@ -65,7 +65,7 @@ def login(): # postman -@app.route('/logout', methods=['POST']) # 退出登录功能 +@app.route('/api/logout', methods=['POST']) # 退出登录功能 def logout(): # 退出登录 ID = session['id'] print(ID) @@ -73,7 +73,7 @@ def logout(): # 退出登录 return jsonify({'result': '注销成功'}) -@app.route('/register', methods=['POST']) # 注册功能实现 +@app.route('/api/register', methods=['POST']) # 注册功能实现 def register(): register_data = request.json # 获取前端发送过来的数据 name = register_data['name'] @@ -88,7 +88,7 @@ def register(): return jsonify({'result': '注册成功'}) -@app.route('/student/get_lesson', methods=['GET']) +@app.route('/api/student/get_lesson', methods=['GET']) def get_lesson(): # 获取课程 student_id = session.get('id') student_lesson = get_lesson_func(student_id) @@ -97,27 +97,27 @@ def get_lesson(): # 获取课程 # 学生获取试卷 -@app.route('/student/get_test', methods=['POST']) +@app.route('/api/student/get_test', methods=['POST']) def get_test(): # 获取试卷以及历史试卷 data = request.json ID = data['student_ID'] return jsonify({"data": fetch_test_func(ID)}) -@app.route('/student/fetch_result', methods=['POST']) # 查找成绩 +@app.route('/api/student/fetch_result', methods=['POST']) # 查找成绩 def fetch_result(): data = request.json ID = data['student_ID'] return jsonify({'result': fetch_result_func(ID)}) -@app.route('/student/get_end_student', methods=['POST']) +@app.route('/api/student/get_end_student', methods=['POST']) def get_end_student(): data = request.json ID = data['student_ID'] return jsonify({'result': find_end_test(ID)}) -@app.route('/student/score_entry', methods=['POST']) +@app.route('/api/student/score_entry', methods=['POST']) def score_entry(): data = request.json ID = data['student_ID'] @@ -138,7 +138,7 @@ def FetchTrainTitle(): # 以下为教师功能————————————————————————————————————————————————————————————————————— -@app.route('/teacher/return_question', methods=['POST']) +@app.route('/api/teacher/return_question', methods=['POST']) def return_question(): data = request.json ID = data['teacher_ID'] @@ -148,7 +148,7 @@ def return_question(): return jsonify({'选择': choice_question, '填空': completion_question, '判断': t_or_f_question}) -@app.route('/teacher/select_class', methods=['POST']) +@app.route('/api/teacher/select_class', methods=['POST']) def select_class(): # 查找每个老师管理的班级 以及在考试管理查找默认班级 teacher_id = request.json['teacher_ID'] # testID =request.json['testID'] @@ -157,23 +157,23 @@ def select_class(): # 查找每个老师管理的班级 以及在考试管理 # print(testID) return jsonify({'Class': class_dic,'default': find_default_class_func(default_class, teacher_id)}) -@app.route('/teacher/change_class', methods=['POST']) +@app.route('/api/teacher/change_class', methods=['POST']) def change_class(): # 查找每个老师管理的班级 以及在考试管理查找默认班级 teacher_id = request.json['teacher_ID'] ClassID=request.json['selectedValue'] return jsonify({'default': find_default_class_func(ClassID,teacher_id)}) -@app.route('/teacher/detaileddata', methods=['POST']) +@app.route('/api/teacher/detaileddata', methods=['POST']) def detaileddata(): data=request.json ClassID=data['selectedValue'] testID=data['testID'] return jsonify({'data':detailed_class(testID,ClassID)}) -@app.route('/teacher/', methods=['POST']) +@app.route('/api/teacher/', methods=['POST']) def find_test(): return -@app.route('/teacher/find_student', methods=['POST']) +@app.route('/api/teacher/find_student', methods=['POST']) def find_student(): # 获取班级学生的具体信息 student_list = [] Data = request.json @@ -184,7 +184,7 @@ def find_student(): # 获取班级学生的具体信息 return [student_succeed, student_list] -@app.route('/teacher/accept_test', methods=['POST']) # 在前端发布成功之后要存入数据库 +@app.route('/api/teacher/accept_test', methods=['POST']) # 在前端发布成功之后要存入数据库 def accept_test(): data = request.json choice_list = data['ChoiceQuestionSet'] @@ -199,11 +199,11 @@ def accept_test(): print('添加成功') return jsonify({'result': '发布成功'}) -@app.route('/teacher/fetch_train_question',methods=["POST"]) +@app.route('/api/teacher/fetch_train_question',methods=["POST"]) def fetch_train_question(): return train_question() -@app.route('/teacher/SendTrainTest',methods=["POST"]) +@app.route('/api/teacher/SendTrainTest',methods=["POST"]) def SendTrainTest(): data=request.json TrainChoice=data['TrainChoice']