我正在使用flask开发一个web界面。 用户登录并到达可以上载文件的html页面。该文件将由内部程序保存和解析(与我的问题无关)
我使用烧瓶表单中的文件字段:
class MyForm(FlaskForm):
file = FileField("DROP YOUR FILE HERE", validators=[DataRequired()])
submit = SubmitField('Submit')
我在主程序中称之为:
@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)
这是我的html页面的主体:
<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>
问题是上传和保存大量数据需要花费大量时间。 所以我想添加一个进度条,但我不知道如何获得下载进度并将其发送到我的html进度条
这就是我请求你帮助的原因。如果你有什么解决办法,我就接受
谢谢
目前没有回答
相关问题 更多 >
编程相关推荐