【问题标题】:post method 405 error in bottle python瓶子python中的post方法405错误
【发布时间】:2017-11-08 05:24:37
【问题描述】:

我尝试使用 post 方法,但收到错误 405。这是我的 python 代码:

@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(tis 页面位于 .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">

请帮忙。

【问题讨论】:

  • 请先格式化您的代码
  • 完成格式化

标签: python html bottle


【解决方案1】:

您可以尝试如下将methods更改为method

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-21
    • 1970-01-01
    相关资源
    最近更新 更多