【问题标题】:python bottle redirect resulting in Error 405 : Method not allowedpython瓶重定向导致错误405:方法不允许
【发布时间】:2020-07-21 17:52:58
【问题描述】:

所以我一直在工作或一个快速的小项目,我有这个问题

from bottle import get, post, request, run, redirect
import threading 

@get('/button')
def button():
    return '''
        <form action="/button" method="post">
            <input type="submit" value="Push"/>
        </form>
    '''
@post
def action():
    print ("button pushed")
    global pushed 
    pushed = True
    redirect("/button")


threading.Thread(target=run, kwargs=dict(host='localhost', port=80)).start()

pushed = False
print("Started")
while 1:

    if pushed:
        print("push recv")
        pushed = False

我正在使用“sudo python3 code.py”运行我的代码

【问题讨论】:

  • 请包含您对服务器进行的 HTTP 调用。

标签: python-3.x redirect http-post bottle http-status-code-405


【解决方案1】:

您尚未将路由附加到您的 @post 声明。应该是:

@post('/button')

【讨论】:

  • 这是一个愚蠢的错误!感谢您指出这一点
猜你喜欢
  • 2014-03-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-10
  • 2021-09-17
  • 1970-01-01
  • 2021-12-20
  • 2017-11-13
相关资源
最近更新 更多