所以我一直在工作或正在做一个小型项目,而我遇到了这个问题
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”运行我的代码
您尚未在@post
声明中附加路线。应该是:
@post('/button')