[python瓶子重定向导致错误405:不允许使用方法

问题描述 投票:0回答:1

所以我一直在工作或正在做一个小型项目,而我遇到了这个问题

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”运行我的代码

python-3.x redirect http-post bottle http-status-code-405
1个回答
0
投票

您尚未在@post声明中附加路线。应该是:

@post('/button')
© www.soinside.com 2019 - 2024. All rights reserved.