1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="UTF-8">
5 <title>Upload new File</title>
6</head>
7<body onload="flashMessage()">
8 <script>
9 function flashMessage() {
10 if ("{{ flash_message }}" == "True") {
11 alert("[YOUR_MESSAGE_HERE]");
12 }
13 }
14 </script>
15
16 <h1>Upload new File</h1>
17 <form method=post enctype=multipart/form-data>
18 <input type=file name=file>
19 <input type=submit value=Upload>
20 </form>
21</body>
22</html>
1from flask import Flask, render_template
2
3app = Flask(__name__)
4
5
6@app.route('/', methods=['GET', 'POST'])
7def upload_file():
8 if request.method == 'POST':
9 #verify if the file is valid
10 #here invoke js to do something (for example flash("test"))
11 return render_template('upload.html', flash_message="True")
12
13 return render_template('upload.html', flash_message="False")
14