概念
- 最轻量级的web框架
安装
pip install web.py
实例代码
import web
urls = (
'/(.*)', 'hello'
)
app = web.application(urls, globals())
class hello:
def GET(self, name):
i = web.input(times=1)
print i.times
if not name:
name = 'world'
for c in xrange(int(i.times)):
print 'Hello,', name + '!'
return 'Hello, ' + name + '!'
if __name__ == "__main__":
web.internalerror = web.debugerror
app.run()
- import web导入web.py模块
- urls, 第一部分为网站的url,第二部门为接受请求的类名称,第二部门处理第一部分的页面
- app = web.application(urls, globals()),创建application,完成应用创建,对象
- class hell:处理url的类
- web.internalerror = web.debugerror开启调试
- app.run()启动应用,开始工作
- 编译成功后,访问http://localhost:8080
简易博客源码参考:https://blog.youkuaiyun.com/caleng/article/details/5712850