I have a simple Flask application that queries a database using a set of parameters and then plots the result. This works fine, but how do I restart application whenever its still ruing and I do a refresh of the page or I click the submit button again?
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def index():
form = InputForm(request.form)
if request.method == 'POST' and form.validate():
data = queryDatabase(form.startdate.data, form.enddate.data)
result = plotData(data)
else:
result = None
retu render_template('view.html', form=form, result=result)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)
----view.html
<form method=post action="">
<table>
{% for field in form %}
<tr>
<td>{{ field.label }}</td>
<td>{{ field }}</td>
</tr>
{% endfor %}
</table>
<p><input type=submit value=Submit></form></p>
<p>
{% if result != None %}
<img src="{{ result }}" width="500">
{% endif %}
</p>
