From 17bf2fa74f78e9ffe53331411db9cd28511a4a11 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Sat, 16 Nov 2024 17:41:06 +0100 Subject: [PATCH] fix: save before loading list Also drop print. This updates the uploaded list correctly. --- upload.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/upload.py b/upload.py index 171fd83..20b174a 100644 --- a/upload.py +++ b/upload.py @@ -39,6 +39,11 @@ def saveimage(image): def index(): """Upload route, a page to upload an image""" imageuploadform = ImageUploadForm() + + if request.method == "POST": + if imageuploadform.validate_on_submit(): + saveimage(imageuploadform.image.data) + uploaded_files = sorted( [ os.path.join(APP.config["IMAGE_FOLDER"], file) @@ -46,10 +51,7 @@ def index(): ], key=os.path.getctime, ) - print(uploaded_files) - if request.method == "POST": - if imageuploadform.validate_on_submit(): - saveimage(imageuploadform.image.data) + return render_template( "upload.html", imageuploadform=imageuploadform,