所以我一直在做一个快速的小项目,我遇到了问题
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')