Compare commits

..

2 Commits

Author SHA1 Message Date
wang 045454f023 docker 2024-06-20 14:56:23 +08:00
wang c6a3e68a84 docker 2024-06-20 14:55:43 +08:00
103 changed files with 142 additions and 96 deletions

0
.gitignore vendored Executable file → Normal file
View File

BIN
README.md Executable file → Normal file

Binary file not shown.

0
app-dm/.dockerignore Executable file → Normal file
View File

2
app-dm/.gitignore vendored Executable file → Normal file
View File

@ -11,6 +11,8 @@
# production
/build
# misc
.DS_Store
.env.local

0
app-dm/Dockerfile Executable file → Normal file
View File

0
app-dm/README.md Executable file → Normal file
View File

0
app-dm/package-lock.json generated Executable file → Normal file
View File

0
app-dm/package.json Executable file → Normal file
View File

0
app-dm/public/favicon.ico Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

0
app-dm/public/index.html Executable file → Normal file
View File

0
app-dm/public/logo192.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

0
app-dm/public/logo512.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

0
app-dm/public/manifest.json Executable file → Normal file
View File

0
app-dm/public/robots.txt Executable file → Normal file
View File

0
app-dm/server/config.js Executable file → Normal file
View File

0
app-dm/server/index.js Executable file → Normal file
View File

0
app-dm/server/router.js Executable file → Normal file
View File

0
app-dm/src/TeacherPages/MarkingPages/Marking.css Executable file → Normal file
View File

0
app-dm/src/TeacherPages/MarkingPages/Marking.jsx Executable file → Normal file
View File

0
app-dm/src/TeacherPages/SendTest/SendTest.css Executable file → Normal file
View File

6
app-dm/src/TeacherPages/SendTest/SendTest.jsx Executable file → Normal file
View File

@ -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,//

0
app-dm/src/TeacherPages/SendTrain/SendTrain.css Executable file → Normal file
View File

6
app-dm/src/TeacherPages/SendTrain/SendTrain.jsx Executable file → Normal file
View File

@ -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,

0
app-dm/src/TeacherPages/TeacherPage.css Executable file → Normal file
View File

2
app-dm/src/TeacherPages/TeacherPage.jsx Executable file → Normal file
View File

@ -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']);

0
app-dm/src/TeacherPages/Trainmanage/Trainmanage.css Executable file → Normal file
View File

0
app-dm/src/TeacherPages/Trainmanage/Trainmanage.jsx Executable file → Normal file
View File

2
app-dm/src/TeacherPages/classlistpages/classId.jsx Executable file → Normal file
View File

@ -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)

0
app-dm/src/TeacherPages/classlistpages/classid.css Executable file → Normal file
View File

View File

View File

@ -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

0
app-dm/src/api/index.js Executable file → Normal file
View File

0
app-dm/src/index.js Executable file → Normal file
View File

0
app-dm/src/logo.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

0
app-dm/src/nav/nav.jsx Executable file → Normal file
View File

0
app-dm/src/nav/style.css Executable file → Normal file
View File

0
app-dm/src/nav/teacherIndex.jsx Executable file → Normal file
View File

0
app-dm/src/pages/Home/Home.css Executable file → Normal file
View File

2
app-dm/src/pages/Home/Home.jsx Executable file → Normal file
View File

@ -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
});
//

0
app-dm/src/pages/Home/img/ad.jpg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 75 KiB

0
app-dm/src/pages/Home/img/logo.jpg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 75 KiB

0
app-dm/src/pages/Home/img/test.jpg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

0
app-dm/src/pages/ListPages/Analyse/AnalysePages.css Executable file → Normal file
View File

0
app-dm/src/pages/ListPages/Analyse/AnalysePages.jsx Executable file → Normal file
View File

0
app-dm/src/pages/ListPages/Subject/Exam.css Executable file → Normal file
View File

4
app-dm/src/pages/ListPages/Subject/Exam.jsx Executable file → Normal file
View File

@ -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

0
app-dm/src/pages/ListPages/Subject/SubjectPage.css Executable file → Normal file
View File

6
app-dm/src/pages/ListPages/Subject/SubjectPage.jsx Executable file → Normal file
View File

@ -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'])

0
app-dm/src/pages/ListPages/Training/Operation1.css Executable file → Normal file
View File

0
app-dm/src/pages/ListPages/Training/Operation1.jsx Executable file → Normal file
View File

0
app-dm/src/pages/ListPages/Training/Operation2.css Executable file → Normal file
View File

0
app-dm/src/pages/ListPages/Training/Operation2.jsx Executable file → Normal file
View File

0
app-dm/src/pages/ListPages/Training/TrainingPage.css Executable file → Normal file
View File

0
app-dm/src/pages/ListPages/Training/TrainingPage.jsx Executable file → Normal file
View File

0
app-dm/src/pages/ListPages/img/bottom.jpg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

0
app-dm/src/pages/ListPages/img/right.jpg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

0
app-dm/src/pages/ListPages/img/top.jpg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

0
app-dm/src/pages/SighUp/SignUpForm.css Executable file → Normal file
View File

2
app-dm/src/pages/SighUp/SignUpForm.jsx Executable file → Normal file
View File

@ -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,

0
app-dm/src/pages/SighUp/SignUpPage.jsx Executable file → Normal file
View File

0
app-dm/src/pages/SighUp/注册页面右.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 205 KiB

After

Width:  |  Height:  |  Size: 205 KiB

0
app-dm/src/pages/SignIn/SignInPage.css Executable file → Normal file
View File

2
app-dm/src/pages/SignIn/SignInPage.jsx Executable file → Normal file
View File

@ -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
});

0
app-dm/src/pages/SignIn/登录页面左.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 304 KiB

After

Width:  |  Height:  |  Size: 304 KiB

0
app-dm/src/postcss.config.js Executable file → Normal file
View File

0
app-dm/src/reportWebVitals.js Executable file → Normal file
View File

0
app-dm/src/router/index.jsx Executable file → Normal file
View File

4
app-dm/src/setupProxy.js Normal file
View File

@ -0,0 +1,4 @@
const proxy=require("http-proxy-middleware")
module.exports=function(app){
app.use(proxy(['/api'],{target:"http://localhost:5000"}))
}

0
app-dm/src/setupTests.js Executable file → Normal file
View File

0
app-dm/src/utils/request.js Executable file → Normal file
View File

0
app-dm/src/vite.config.js Executable file → Normal file
View File

0
app-dm/tailwind.config.js Executable file → Normal file
View File

54
build.sh Executable file → Normal file
View File

@ -1,3 +1,51 @@
docker compose build
docker compose build build-dmpython
docker compose build build-frontend
#!/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

23
docker-compose.yml Executable file → Normal file
View File

@ -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

33
docker/base-dm/Dockerfile Executable file → Normal file
View File

@ -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
&& chmod +x DMInstall.bin
USER dmdba

22
docker/base/Dockerfile Normal file
View File

@ -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/*

0
docker/build-dmpython/Dockerfile Executable file → Normal file
View File

2
docker/build-dmpython/auto_install.xml Executable file → Normal file
View File

@ -115,7 +115,7 @@
</DB_PARAMS>
<!--是否创建数据库实例的服务,取值范围: Y/N y/n不允许为空不初始化数据库将忽略此节点。非root用户不能创建数据库服务。 -->
<CREATE_DB_SERVICE>Y</CREATE_DB_SERVICE>
<CREATE_DB_SERVICE>N</CREATE_DB_SERVICE>
<!--是否启动数据库,取值范围: Y/N y/n不允许为空不创建数据库服务将忽略此节点。 -->
<STARTUP_DB_SERVICE>N</STARTUP_DB_SERVICE>

0
docker/code-server/.editorconfig Executable file → Normal file
View File

0
docker/code-server/LICENSE Executable file → Normal file
View File

0
docker/code-server/package_versions.txt Executable file → Normal file
View File

View File

View File

View File

0
docker/nginx/Dockerfile Executable file → Normal file
View File

0
docker/nginx/default.conf Executable file → Normal file
View File

0
docker/nginx/nginx.conf Executable file → Normal file
View File

0
docker/nginx/start.sh Executable file → Normal file
View File

0
docker/ssh-server/Dockerfile Executable file → Normal file
View File

24
python/Dockerfile Executable file → Normal file
View File

@ -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"]
CMD ["gunicorn", "-w", "3", "-t", "60", "-b", "0.0.0.0:8000", "app:app"]

36
python/app.py Executable file → Normal file
View File

@ -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']

0
python/requirements.txt Executable file → Normal file
View File

Some files were not shown because too many files have changed in this diff Show More