這是我的代碼響應:的Python瓶錯誤ValueError異常:View功能沒有返回
@app.route('/registercheck', methods=['GET', 'POST'])
def registercheck():
checkusername = g.db.execute('select uname from users where uname = ?', (request.form['usernameR'],))
checkpassword = g.db.execute('select pword from users where uname = ?', (request.form['usernameR'],))
arraycheckr = checkpassword.fetchall()
if request.method == 'POST':
encryptpword = hashlib.md5()
encryptpword.update(request.form['passwordR'])
encryptpword.digest()
if len(arraycheckr) == 0 and checkpassword == encryptpword:
if len(request.form['usernameR']) < 6:
flash('Username must be at least 6 characters')
return redirect(url_for('register'))
if len(request.form['passwordR']) < 4:
flash('Password must be at least 4 characters')
return redirect(url_for(register))
if checkusername == request.form['usernameR']:
flash('Username is already taken')
return redirect(url_for(register))
else:
g.db.execute('insert into users (uname, pword) values (?, ?);', (request.form['usernameR'], encryptpword))
g.db.commit()
os.mkdir(os.path.join(app.config['UPLOAD_FOLDER'], request.form['usernameR']))
return redirect(url_for('upload'))
我看了一下類似這樣的其他職位,但我還是不明白爲什麼它拋出這個問題。重定向看起來很好(在html中)。
那麼,如果方法不是POST,你的代碼會返回什麼?或者,如果它發佈並且密碼無效? –
當請求不是「POST」請求等時會發生什麼? –