I have a Flask server, and something like that:
@app.route("/page", methods=['GET', 'POST'])
def page():
is_working = False
if (request.method == 'POST'):
is_working = True
do_long_task()
is_working = False
return render_template('page.html', is_working)
do_long_task is a process that can took some time. I want to alter the template considering if the process is running or not. With the example above the server simply wait for do_long_task() to finish to render the template. I ideally would like something like this:
@app.route("/page", methods=['GET', 'POST'])
def page():
is_working = False
if (request.method == 'POST'):
is_working = True
render_template('page.html', is_working)
do_long_task()
is_working = False
render_template('page.html', is_working)
But this won't work because the template once rendered must be returned (and thus page must finish) to be taken into account.
How can I do that ?