Flask Redirect
Flask Tip:
In Flask, the
redirect()
function is used to redirect a user to a different URL.
redirect()
can greatly improve the navigation through a site by automatically redirecting users to their expected pages.👇
@app.route('/add_stock', methods=['GET', 'POST']) def add_stock(): if request.method == 'POST': # ... save the data ... return redirect(url_for('list_stocks')) # <-- !! return render_template('add_stock.html')