@app.route('/signup',methods=['GET','POST'])
def secret():
form3=SecretForm()
if request.method=='POST':
secret=form3.secret.data
if secret=='111111':
return redirect(url_for('signup2'))
elif secret!='111111':
abort(401)
elif request.method=='GET':
return render_template('signup1.html',form=form3)
@app.route('/signup2',methods=['GET','POST'])
def signup2():
form4=LoginForm()
if request.method=='POST':
name1=form4.name.data
pwd1=form4.pwd.data
cursor1=conn1.cursor()
cursor1.execute('insert into user (name,pwd) values (name1,pwd1)')
cursor1.close()
return 'sign up successfully'
else:
return render_template('signup2.html',form=form4)
以上为我打的代码。
当利用redirect跳转到/signup2后,填写完表单并上传网页就会立马跳转回/signup并显示401错误(就是secret()函数中secret参数不等于111111后的内容),不知道是什么原理
标签:return,flask,求助,111111,signup2,secret,form4,网页,POST From: https://blog.csdn.net/DrOctopus1145/article/details/137471072