2016-11-25 4 views
0

私は1ページにいくつかのフォームを持つフラスコ/フラスコを使用しています。私のapp.pyコードステートメントは、1つのフォームの一部である最初の2つのifステートメントで動作しますが、3番目または4番目のifステートメントでは400のエラーで失敗します。私が見解でそれらを交換すれば、彼らは働くでしょう。また、私のタブは、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コードを残しました。

答えて

0

慎重に比較した後、私はこの問題に気づいた:

abortOn= request.form.getlist["Abort"] == "On" 

    Abortoff= request.form.getlist["Abort"] == "Abort" 

私はそれを変更:

abortOn= request.form.get["Abort"] == "On" 

    Abortoff= request.form.get["Abort"] == "Abort" 
関連する問題