Get Next Url Using Flask Redirect
I am following this information here, all seems good, but I need to know how to load the originally requested url from the new login page on the second to last line. @app.route('/l
Solution 1:
Try this out:
@app.route('/login', methods=['GET', 'POST'])
def login():
error = None
if request.method == 'POST':
username = request.form['username']
password = request.form['password']
if not models.check_auth(username, password):
error = 'Please try again.'
else:
return redirect(request.args.get("next") or url_for("admin"))
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
return render_template('login.html', error=error)
Post a Comment for "Get Next Url Using Flask Redirect"