最初的测试代码还是比较能清晰的反映出代码的意图
文件: code.py
启动: python code.py
查看:
http://127.0.0.1:8080/app1
http://127.0.0.1:8080/app1?id=100
import web urls = ( '/app1', 'App1', '/app2', 'App2', ) web.config.debug = False app = web.application(urls, globals()) class PageBase: def __init__(self): self.funGET = self.GET self.GET = self.get def get(self): wi = web.input() if hasattr(wi,"id"): self.s = wi.id else: self.s = "hello" return self.funGET() class App1(PageBase): def GET(self): return self.s class App2(PageBase): def GET(self): return self.s if __name__ == "__main__": app.run()