diff --git a/工具v4/templates/show_image.html b/工具v4/templates/show_image.html index cfbcbcc8..aa0a7c33 100644 --- a/工具v4/templates/show_image.html +++ b/工具v4/templates/show_image.html @@ -23,6 +23,9 @@

+
+

过往备注

+ {{ old_remarks|safe }}

题目内容

Question Image diff --git a/工具v4/备注信息收集.py b/工具v4/备注信息收集.py index 784bb305..edfebc3c 100644 --- a/工具v4/备注信息收集.py +++ b/工具v4/备注信息收集.py @@ -18,6 +18,10 @@ def show_image(): val = (id,) mycursor.execute(sql,val) content = mycursor.fetchall()[0][0] + sql = "SELECT date,remark_content FROM remarks WHERE ID = %s;" + mycursor.execute(sql,val) + remark_list = sorted(mycursor.fetchall(),key=lambda item:item[0],reverse=True) + print(remark_list) mydb.close() content_hash = hashlib.sha256(content.encode("utf8")).hexdigest() # print(content_hash,type(content_hash)) @@ -45,7 +49,11 @@ def show_image(): mycursor.execute("INSERT INTO pics (ID,pic,date,hash) VALUES (%s,%s,%s,%s)",(id,image_data,currentdate,content_hash)) mydb.commit() mydb.close() - return render_template('show_image.html', image_path=f'/static/{id}.png') + output_string = "" + for rem in remark_list: + output_string += f"{rem[0]} {rem[1]}\n" + output_string = re.sub(r"\n","

\n",output_string) + "
\n" + return render_template('show_image.html', image_path=f'/static/{id}.png', old_remarks = output_string) @app.route('/submit_remarks', methods=['POST'])