I'm developing a web interface by using flask. The user log and reach an html page where a file can be upload. This file will be save and parse by an internal program (no relation with my problem)
I use a File Field in a Flask Form:
class MyForm(FlaskForm):
file = FileField("DROP YOUR FILE HERE", validators=[DataRequired()])
submit = SubmitField('Submit')
I call it in my main programm:
@app.route('/upload', methods=['GET', 'POST'])
@login_required
def uploadfile():
form = MyForm()
if form.validate_on_submit():
file = form.file
file.data.save(os.path.join("path/to/", secure_filename("filename")))
flash("File added")
return redirect(url_for('uploadfile'))
return render_template("upload.html",form=form)
and here is the body of my html page:
<form action="{{url_for('uploadfile')}}" method="post" enctype="multipart/form-data" novalidate>
{% with messages = get_flashed_messages() %}
{% if messages %}
{% for message in messages %}
<p class="error">{{ message }}</p>
{% endfor %}
{% endif %}
{% endwith %}
{{ form.csrf_token }}
{{form.fichier}}
{% for error in form.fichier.errors %}
<span style="color: red;">[{{ error }}]</span>
{% endfor %}
<p>{{ form.submit() }}</p>
</form>
The problem is uploading and saving a lot of data take lots of time. So i want to add a progress bar but i don't know how to get the download progress and send it to my html progress bar.
This is why i ask your help. If you have any solution i will take it.
Thanks you