From af02b6f162b0b5b7230dd378681b3f1637948ed6 Mon Sep 17 00:00:00 2001 From: Kakune55 Date: Wed, 10 Apr 2024 17:11:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=B8=8A=E4=BC=A0=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 11 +++++++ templates/upload.html | 76 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 templates/upload.html diff --git a/main.py b/main.py index cec4a37..147cb6c 100644 --- a/main.py +++ b/main.py @@ -82,6 +82,17 @@ def view(bookid): # 接口 return bookid +@app.route('/upload', methods=["GET", "POST"]) #文件上传 +def upload_file(): + if request.method == "GET": + return render_template("upload.html") + uploaded_file = request.files['file'] + if uploaded_file.filename != '': + uploaded_file.save( config.get("file", "inputdir") + "/" + uploaded_file.filename) + file.auotLoadFile() + return redirect("/") + + if __name__ == "__main__": appinit() app.run( diff --git a/templates/upload.html b/templates/upload.html new file mode 100644 index 0000000..8acdd32 --- /dev/null +++ b/templates/upload.html @@ -0,0 +1,76 @@ + + + + + + 文件上传 + + + + +
+

文件上传

+
+
+ +
+ +
+ +
+
+
+ + +
+ + + +