我来自 Java REST 背景到Python
on Google App Engine's
. 我需要一些使用webapp2
路径参数的帮助。下面是 Java 如何读取请求的示例。有人会将代码翻译成python如何读取它webapp2
吗?
// URL: my_dogs/user_id/{user_id}/dog_name/{a_name}/breed/{breed}/{weight}
@Path("my_dogs/user_id/{user_id}/dog_name/{a_name}/breed/{breed}/{weight}")
public Response getMyDog(
@PathParam("user_id") Integer id,
@PathParam("a_name") String name,
@PathParam("breed") String breed,
@PathParam("weight") String weight
){
//the variables are: id, name, breed, weight.
///use them somehow
}
我已经浏览了 google 上的示例(https://developers.google.com/appengine/docs/python/gettingstartedpython27/usingwebapp)。但我不知道如何扩展简单
app = webapp2.WSGIApplication([('/', MainPage),
('/sign', Guestbook)],
debug=True)