简体   繁体   中英

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.

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:

@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')

Code in html: htmlcode Thanks

Add this to your <head>

<meta http-equiv="refresh" content="30">

Replace 30 with how many seconds you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM