From 9e888c1d59590bc005f5c2057693a49b0c35909f Mon Sep 17 00:00:00 2001 From: crunk Date: Sat, 16 Nov 2024 10:10:30 +0100 Subject: [PATCH] no master branch --- templates/upload.html | 16 +++++++++++++++- upload.py | 8 ++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/templates/upload.html b/templates/upload.html index fcacef4..29ecc39 100644 --- a/templates/upload.html +++ b/templates/upload.html @@ -4,11 +4,25 @@ Perma-Upload a picture + -
+ {{ imageuploadform.csrf_token }}
+ Upload an image here {{ imageuploadform.image.label }} {{ imageuploadform.image }} {% for message in imageuploadform.image.errors %} diff --git a/upload.py b/upload.py index dc6439c..917137f 100644 --- a/upload.py +++ b/upload.py @@ -6,10 +6,10 @@ from wtforms import ( SubmitField, ) -# config me here +# config me here APP = Flask(__name__, static_folder="static") APP.config["IMAGE_FOLDER"] = "static/images" -ALLOWED_FILES = ["jpg", "png", "gif", "webp"] +ALLOWED_FILES = ["jpg", "png", "gif", "webp"] # don't config these lines APP.config["SECRET_KEY"] = os.urandom(24) @@ -17,8 +17,8 @@ APP.config["SECRET_KEY"] = os.urandom(24) class ImageUploadForm(FlaskForm): """Image upload form.""" image = FileField( - "Upload an image:", - validators=[FileAllowed(ALLOWED_FILES, "Images only!")], + "image:", + validators=[FileAllowed(ALLOWED_FILES, f"Images only, please use any of the following file extensions: {(", ").join(ALLOWED_FILES)}")], ) submit = SubmitField("Submit")