开发者

Python Routes, giving request method

I have something like using python routes, How to map request method like post, get, delete here...

开发者_开发知识库
mapper.connect("/user", controller=user_controller, action="user")


Add a condition, specify the HTTP method required and map to the appropriate controller action. For example, your snippet could be rewritten as:

mapper.connect("/user", controller=user_controller, action="get_user", conditions=dict(method=["GET"]))
mapper.connect("/user", controller=user_controller, action="add_user", conditions=dict(method=["POST"]))

See the docs at http://routes.groovie.org/setting_up.html#conditions

Note that if you only want to specify one HTTP method and have all other requests handled by one route, include a matching route without the condition after the more specific route:

## Handle GET requests
mapper.connect("/user", controller=user_controller, action="get_user", conditions=dict(method=["GET"]))
## Handle all other, non-GET requests
mapper.connect("/user", controller=user_controller, action="add_user")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜