web.py中urls示例
2016-12-02 20:04
369 查看
1、urls一般都说多路由,我认为这个其实就是改变http不通的请求从而得到不同服务端程序的响应,从而将业务细化
2、代码示例
3、说明
通过运行127.0.0.1:8000/demo1则响应内容为demo2类中内容
通过运行127.0.0.1:8000/demo2则响应内容为demo1类中内容
2、代码示例
#coding:utf-8 import web #urls rule urls=( "/(demo2.*)","demo1", "/(demo1.*)","demo2" ) #application information app=web.application(urls,globals()) class demo1: def GET(self, arg1): web.header('Content-Type','text/html;charset=UTF-8') return '1111111,'+'11111111'+'!' print "this is application demo1" class demo2: def GET(self, arg1): web.header('Content-Type', 'text/html;charset=UTF-8') return '22222222222,' + '222222222222' + '!' print "this is application demo2" if __name__ == "__main__": app.run()
3、说明
通过运行127.0.0.1:8000/demo1则响应内容为demo2类中内容
通过运行127.0.0.1:8000/demo2则响应内容为demo1类中内容
相关文章推荐
- 使用BAE的基于Web.py的简单博客程序
- web.py中调用文件夹内模板的方法
- web.py在SAE中的Session问题解决方法(使用mysql存储)
- 在windows下快速搭建web.py开发框架方法
- web.py 十分钟创建简易博客实现代码
- web.py在模板中输出美元符号的方法
- 浅析Python的web.py框架中url的设定方法
- Python开发WebService系列教程之REST,web.py,eurasia,Django
- web.py获取上传文件名的正确方法
- 在windows下快速搭建web.py开发框架方法
- web.py 十分钟创建简易博客实现代码
- 浅析Python的web.py框架中url的设定方法
- mako模板
- 搭建web.py开发框架
- 封装web.py发送邮件
- 使用webpy写小偷程序真是太方便了
- python web多sitemap创建更新解决方案
- Python web多sitemap创建更新解决方案
- 80个Python经典资料(教程+源码+工具)汇总
- web.py学习随笔