目录
URL完全匹配(具体的url)
/index
URL模糊匹配(你根本就不知道index后面是什么,它根本不会返回参数)
/index/\\d
URL带组匹配(主要有个\'()\’,它的作用主要是返回参数,你处理的类中一定要有个参数接受)
/baidu/(.*)
实例
import web urls=(\'/index\',\'AbsoluteUrl\', \'/index/\\d\',\'AmbiguousUrl\', \'/index/(.*)\',\'GroupUrl\') #具体的url处理类 class AbsoluteUrl: def GET(self): web.header(\'Content-type\',\'text/html;charset=utf-8\') return u\'URL完全匹配\' #模糊的url处理类 class AmbiguousUrl: def GET(self): web.header(\'Content-type\',\'text/html;charset=utf-8\') return u\'URL模糊匹配\' #分组的url处理类 class GroupUrl: def GET(self,name): #如果你这里是带组匹配,一定要添加参数,用来接收你返回的参数 web.header(\'Content-type\',\'text/html;charset=utf-8\') return u\'URL带组匹配--\'+name app=web.application(urls,globals()) if __name__ == \'__main__\': app.run()
问题
1. urls为何不能使用dict,难道和它的原理有关
2. globals() 的作用还有哪些
3. 为何http://0.0.0.0:8080/,为何我们运行的时候一定要localhost:8080,这样设计有什么好处?
以上就是python脚本框架webpy的url映射详解的详细内容,更多关于webpy的url映射的资料请关注其它相关文章!
© 版权声明
THE END
暂无评论内容