I am trying to call a function in Flask by clicking a button. When the button is clicked, the following script runs.
JS
$("#load_btn").click(function() {
$.get("/callback");
}
Flask
@app.route('/callback')
def callback():
print('called')
... # code here that needs to run before rendering callback
return render_template('callback.html')
The problem here is, called
is printed, and GET /callback HTTP/1.1 200
is logged as well, but callback.html
is not rendered - the page stays the same. I'm guessing this is probably not the best approach to solving this problem, but if so what is the recommended approach?