2017-10-29 92 views
0

我試圖用POST方法,但得到錯誤405.這是我的Python代碼:POST方法405錯誤瓶蟒蛇

@route('/') 
def home(): 
    return template('driver_homepage(2)') 
@route('/submit' , methods = ['GET', 'POST', 'PUT']) 
    def calculate(): 
    zone = request.form['zone'] 
    #...... 
    ans = eligorithm.Estimation 
    return template('driver_finalpage-2') 
    #return template('driver_finalpage-2', ans=ans) 
run(reloader=True) 

當我點擊,而不是要在HTML頁面上我的計算按鈕, driver_finalpage-2(該頁面在.tpl和.html中,我在這裏使用.tpl)顯示錯誤。 HTML格式:

<form method="post" action="/submit">  
<!-- ...(in here taking input in various fields) --> 
<input class="btn btn-primary" type="submit" value="Calculate"> 

請幫忙。

+0

請fomat代碼首先 – pigletfly

+0

進行格式化 –

回答

0

您可以嘗試改變methodsmethod如下

@route('/submit' , method=['GET', 'POST', 'PUT']) 
def calculate(): 
    ...