web.py初体验
#coding=utf8
import web
urls = (
'/(.*)/', 'redirect',
'/', 'hello',
'/post', 'to_mcu',
)
app = web.application(urls, globals())
class hello:
def GET(self):
return "<form action='/post' method='post'><p><button type='submit' name='CMD' title='开' accesskey='k' value='01'>开</button></p><p><button type='submit' name='CMD' title='关' accesskey='g' value='00'>关</button></p><p><button type='submit' name='CMD' title='闪' accesskey='s' value='88'>闪</button></p></form>"
class to_mcu:
def POST(self):
return web.input().CMD
class redirect:
def GET(self, path):
web.seeother('/' + path)
if __name__ == "__main__":
app.run()
作者:catmelo
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。

浙公网安备 33010602011771号