双向uri路由
biro的Python项目详细描述
#biro
>双向uri路由
``python
8
路径(列表文章,限制=10)#/文章?限量=10
match('get',“/article/309/article/309”)(article,{“article{id”:“309”})
match('post',“/article/309”)(none,none)
```
router=router=router()
router=router()
>router.router.append('detele','/article/< lt lt'lt('detele',/article/article/<“article_id>;”,处理程序)
router.match('patch',“/path’)
router.path(handler,q=val)
````
` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `>
定义应用程序(环境,启动响应):
处理程序,params=匹配(environ['request_method'].upper(),
environ['path_info'])
如果处理程序:
状态='200正常'
响应=处理程序(**params)
否则:
状态='404未找到'
响应='page未找到'
开始响应(状态,[('content-type','text/html;charset=utf-8')])
返回[response.encode('utf-8')]
````
````
$gunicorn示例:application
```
>双向uri路由
``python
8
路径(列表文章,限制=10)#/文章?限量=10
match('get',“/article/309/article/309”)(article,{“article{id”:“309”})
match('post',“/article/309”)(none,none)
```
router=router=router()
router=router()
>router.router.append('detele','/article/< lt lt'lt('detele',/article/article/<“article_id>;”,处理程序)
router.match('patch',“/path’)
router.path(handler,q=val)
````
` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `>
定义应用程序(环境,启动响应):
处理程序,params=匹配(environ['request_method'].upper(),
environ['path_info'])
如果处理程序:
状态='200正常'
响应=处理程序(**params)
否则:
状态='404未找到'
响应='page未找到'
开始响应(状态,[('content-type','text/html;charset=utf-8')])
返回[response.encode('utf-8')]
````
````
$gunicorn示例:application
```