Initializing flash messages and adding url_for() in templates (#9)

* adding url_for to prevent errors when changing routes

* Update layout.html

* Update app.py
This commit is contained in:
Ilya Patrzykat-Hannas
2021-05-03 02:29:46 -03:00
committed by GitHub
parent 02c7b295c4
commit 48942f9e4a
2 changed files with 17 additions and 7 deletions

4
app.py
View File

@@ -108,12 +108,12 @@ def FUN_upload_image():
if request.method == 'POST':
# check if the post request has the file part
if 'file' not in request.files:
flash('No file part')
flash('No file part', category='danger')
return(redirect(url_for("FUN_private")))
file = request.files['file']
# if user does not select file, browser also submit a empty part without filename
if file.filename == '':
flash('No selected file')
flash('No selected file', category='danger')
return(redirect(url_for("FUN_private")))
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)