Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a refresh button in Flask?

Tags:

python

flask

My app takes some parameters from a form, uses it as input for another script, and then returns the output. How can I create a refresh button to redirect the user on the initial page without output? I tried this code in the template:

<form action= {{url_for('index')}} method='POST'> 
    <input type='submit' value="REFRESH">
</form>

But this gave me an error that the "View function did not return a response". I also tried:

<form action= {{redirect(url_for('index'))}} method='POST'>
    <input type='submit' value="REFRESH">
</form>

But this gave me the error "'redirect' is undefined" even though my view imported both redirect and url_for.

like image 976
Denis Avatar asked Dec 25 '22 22:12

Denis


1 Answers

You don't need to submit a form to clear the values in it. You can use a reset button.

<input type="reset" value="REFRESH">

This will restore the values -- or lack thereof -- from when the page loaded.

like image 195
dirn Avatar answered Dec 28 '22 10:12

dirn