备注收集功能已能正确显示题目图片(长题目只有第一页)
This commit is contained in:
parent
515e17b1b8
commit
5f60529a0e
|
|
@ -2,6 +2,12 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>输入备注</title>
|
||||
<style>
|
||||
img {
|
||||
width: 30%; /* Set the width of the image */
|
||||
height: auto; /* Maintain aspect ratio */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>输入备注</h1>
|
||||
|
|
@ -12,7 +18,7 @@
|
|||
<select id="category" name="category">
|
||||
<option value="主要错误">主要错误</option>
|
||||
<option value="主要错因">主要错因</option>
|
||||
<option value="主要错因">批改建议</option>
|
||||
<option value="批改建议">批改建议</option>
|
||||
<option value="其他">其它</option>
|
||||
</select><br><br>
|
||||
<input type="submit" value="提交备注">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from flask import Flask, render_template, request, redirect, url_for
|
||||
import os
|
||||
import os,shutil
|
||||
from database_tools_2 import *
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
|
@ -10,10 +11,27 @@ def index():
|
|||
@app.route('/show_image', methods=['POST'])
|
||||
def show_image():
|
||||
if request.method == 'POST':
|
||||
global question_number
|
||||
question_number = request.form['question_number']
|
||||
id = request.form['question_number'].zfill(6)
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = "tiku")
|
||||
mycursor = mydb.cursor()
|
||||
sql = "SELECT content FROM problems WHERE ID = %s;"
|
||||
val = (id,)
|
||||
mycursor.execute(sql,val)
|
||||
content = mycursor.fetchall()[0][0]
|
||||
mydb.close()
|
||||
latex_raw = ReadTextFile("模板文件/独立文件模板.txt")
|
||||
latexdata = StringSubstitute(r"<<待替换\d*>>",latex_raw,[content])
|
||||
makedir("临时文件/pics")
|
||||
currentdate = GetDate()
|
||||
currenttime = GetTime()
|
||||
SaveTextFile(latexdata,f"临时文件/pics/ID{id}-{currentdate}-{currenttime}.tex")
|
||||
os.system(f"xelatex -interaction=batchmode -output-directory=临时文件/pics ID{id}-{currentdate}-{currenttime}.tex")
|
||||
os.chdir("临时文件/pics")
|
||||
os.system(f"pdftocairo -png -r 600 ID{id}-{currentdate}-{currenttime}.pdf")
|
||||
os.chdir("../..")
|
||||
shutil.copy(f"临时文件/pics/ID{id}-{currentdate}-{currenttime}-1.png",f"static/{id}.png")
|
||||
|
||||
return render_template('show_image.html', image_path=f'/static/{question_number}.png')
|
||||
return render_template('show_image.html', image_path=f'/static/{id}.png')
|
||||
|
||||
@app.route('/submit_remarks', methods=['POST'])
|
||||
def submit_remarks():
|
||||
|
|
|
|||
Reference in New Issue