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")