我关注这个information here,一切似乎都很好,但我需要知道如何从第二行到最后一行的新登录页面加载最初请求的URL。
@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(url_for(**next**))
return render_template('login.html', error=error)
答案 0 :(得分:0)
试试这个:
@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)