Browse Source

no master branch

main
crunk 7 days ago
parent
commit
9e888c1d59
  1. 16
      templates/upload.html
  2. 8
      upload.py

16
templates/upload.html

@ -4,11 +4,25 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Perma-Upload a picture</title>
<style media="screen">
body {
background-image: url({{ url_for('static', filename='content/glit_background.gif')}});
}
#uploadform{
background: #f9f871;
margin: auto;
padding: 1em;
width: 30em;
min-height: 5em;
}
</style>
</head>
<body>
<form method="POST" enctype="multipart/form-data">
<form method="POST" enctype="multipart/form-data" id="uploadform">
{{ imageuploadform.csrf_token }}
<fieldset class="fileupload-field">
<legend>Upload an image here</legend>
{{ imageuploadform.image.label }}
{{ imageuploadform.image }}
{% for message in imageuploadform.image.errors %}

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

Loading…
Cancel
Save