例一:
import web urls= (‘/(.*)‘,‘index‘) app= web.application(urls,globals()) class index: def GET(self, name): if not name: name = ‘world‘ web.header(‘Content-Type‘,‘text/html; charset=UTF-8‘) return ‘python web dgx‘ if __name__ == "__main__": app.run()
运行之后,浏览器输入
例二:
import web urls = (‘/(.*)‘, ‘hello‘) app= web.application(urls,globals()) class hello: def GET(self, name): i = web.input(times=1) if not name: name = ‘world‘ for c in xrange(int(i.times)): print ‘Hello,‘, name+‘!‘ return ‘hello ,%s‘ % name if __name__ == "__main__": app.run()
运行之后,浏览器输入
参考文章:http://www.oschina.net/question/5189_4306
时间: 2024-10-19 21:23:41