我必须创建两个登录页面。其中一个返回公司生产的所有巧克力和其他返回个别巧克力的细节。你知道吗
我试过这个,但没用。你知道吗
@app.route('/login', methods=['GET','POST'])
@app.route('/login2', methods=['GET','POST'])
def login():
error = None
if request.method =='POST':
un = request.form['username']
pw = request.form['password']
#check if username and password is correct and store the result in check
if check == "error":
error = 'Invalid Credentials. Please try again.'
else:
return redirect(url_for('login2'))
return render_template('login.html', error = error)
if __name__ == '__main__':
app.run(debug = True)
def login2():
error = None
if request.method =='POST':
un = request.form['username']
pw = request.form['password']
#check if username and password is correct and store the result in check
if check=="error":
error = 'Invalid Credentials. Please try again.'
else:
return redirect(url_for('home'))
return render_template('login2.html', error=error)
但这会产生一个错误,即无法为login2构建url。你是说登录吗? 我使用标准模板登录html页面
路由必须位于它调用的函数的正上方,如下所示:
相关问题 更多 >
编程相关推荐