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()

 

posted @ 2013-05-03 17:41  catmelo  阅读(242)  评论(0编辑  收藏  举报