[英]Reloading form in html page without refreshing the whole page through render template flask
I want to reload just the form part in html page which contains some dynamic plots so that once the form gets submitted I can get the details in python file using flask.我只想重新加载包含一些动态图的 html 页面中的表单部分,以便一旦提交表单,我就可以使用 Flask 获取 python 文件中的详细信息。
Currently I am rendering the template and the whole page is getting refreshed is there any way to not refresh the whole page after submitting the form.目前我正在渲染模板,整个页面正在刷新,有什么方法可以在提交表单后不刷新整个页面。
Code in python: python中的代码:
@application.route('/form2', methods=['POST'])
def form2():
if request.method == 'POST':
features = [x for x in request.form.values()]
with open(r'Operator_comments.csv', 'a') as f:
writer = csv.writer(f)
writer.writerow(features)
return render_template('index.html')
Add this to your <head>
将此添加到您的
<head>
<meta http-equiv="refresh" content="30">
Replace 30 with how many seconds you want.将 30 替换为您想要的秒数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.