0
我正在一個頁面上使用燒瓶/燒瓶跆拳道與幾種形式。我的app.py代碼語句與前兩個if語句一起工作,它是一個表單的一部分,但在第3個/第4個if語句中發生400錯誤。如果我在視圖中交換它們,它們將起作用。另外我的tabbing似乎關閉在stackoverflow,但它在我的ide上很好。Python窗體400錯誤多個請求
app.py
if request.method == 'POST':
###delete
delete = request.form["add"] == 'Delete'
if delete:
print "here at add elete"
#One
selectedOne = request.form.getlist('selectAddressOne')
any_selected = bool(selectedOne)
if any_selected is True:
wallet.autobtcaddress01 = ''
db.session.add(wallet)
db.session.commit()
return redirect(url_for('wallet.walletPageAutoWithdraw', username=user.username))
Add = request.form["add"] == 'Add'
if Add:
selectedOne = request.form.getlist('selectAddressOne')
any_selected = bool(selectedOne)
if any_selected is True:
print "here"
wallet.autobtcaddress01 = form.addressOne.data
db.session.add(wallet)
db.session.commit()
return redirect(url_for('wallet.walletPageAutoWithdraw', username=user.username))
abortOn= request.form.getlist["Abort"] == "On"
if abortOn:
print "abort on"
wallet.autostatus = "Active"
db.session.add(wallet)
db.session.commit()
return redirect(url_for('wallet.walletPageAutoWithdraw', username=user.username))
Abortoff= request.form.getlist["Abort"] == "Abort"
if Abortoff:
wallet.autostatus = "Off"
db.session.add(wallet)
db.session.commit()
return redirect(url_for('wallet.walletPageAutoWithdraw', username=user.username))
的Html
<div id="TurnonorOff">
<form method=POST action="">
<input class="btn btn-default" type=submit value="On" name="Abort">
<input class="btn btn-danger" type=submit value="Abort" name="Abort">
</form>
</div>
<div id="Form5Checkbox">
{{ render_field(form.selectAddressFive, prefs='no')}}
</div>
<div id="Form5">
{{ render_field(form.addressFive,value=wallet.btcaddress05,
autocomplete="off", type="text", size='50') }}
<div id="TurnonorOff">
<form method=POST action="">
<input class="btn btn-default" type=submit value="On" name="Abort">
<input class="btn btn-danger" type=submit value="Abort" name="Abort">
</form>
</div>
<div id="WalletAutoButtonList">
<input class="btn btn-primary" type=submit value="Add" name="add">
<input class="btn btn-danger" type=submit value="Delete" name="add">
</div>
</div>
</form>
我確實忽略了一些HTML/Python代碼,因爲我認爲這是不必要的長和不相關的代碼。