我正在使用燒瓶。這是我的登錄功能:燒瓶重定向不起作用
@app.route("/", methods=["GET", "POST"])
def login():
if request.method == "POST" and "imei" in request.form and "password" in request.form:
imei = request.form["imei"]
password = request.form["password"]
worked, name = checkDB(imei, password)
if worked:
uid = hashlib.sha256(imei.encode('utf-8')).hexdigest()
u = User(imei, name, password, uid)
USERS[uid] = u
login_user(u)
#return request.args.get("next")
return redirect(url_for("analyzer")) #THIS DOESENT WORK
else:
return redirect(url_for("login") + "?failure=true")
elif request.method == "GET" and request.args.get("failure"):
return render_template("auth.html", fail="true")
else:
return render_template("auth.html", fail="false")
當行試圖觸發(標記此DOESENT工作之一),它重定向到:/?next=%2Fwebike%2Fanalyzer
。
的分析很簡單:
@app.route('/analyzer', methods=['GET'])
@login_required
def analyzer():
return render_template('index.html')
我在做什麼錯?如果用戶名和密碼錯誤,一切都按預期工作。
u.get_id()返回什麼? – dirn 2014-10-09 14:19:04
「login_user」之後,您希望在哪裏看到此運行? – Tommy 2014-10-09 14:31:19
'u = User(imei,name,password,uid)'後。 – dirn 2014-10-09 14:32:04