相关疑难解决方法(0)

webapp2.Route带有可选的前导部分

我正在学习webapp2框架及其强大的Route机制.

我的应用程序应该接受这样的URI:

/poll/abc-123
/poll/abc-123/
/poll/abc-123/vote/       # post new vote
/poll/abc-123/vote/456    # view/update a vote
Run Code Online (Sandbox Code Playgroud)

民意调查可以选择组织成类别,因此上述所有内容也应该如下:

/mycategory/poll/abc-123
/mycategory/poll/abc-123/
/mycategory/poll/abc-123/vote/
/mycategory/poll/abc-123/vote/456
Run Code Online (Sandbox Code Playgroud)

我的配置错误:

app = webapp2.WSGIApplication([
    webapp2.Route('/<category>/poll/<poll_id><:/?>', PollHandler),
    webapp2.Route('/<category>/poll/<poll_id>/vote/<vote_id>', VoteHandler),
], debug=True)
Run Code Online (Sandbox Code Playgroud)

问题:如何修复配置?

如果可能,应针对GAE CPU时间/托管费进行优化.例如,如果我为每个条目添加两行可能会更快:一行包含类别,另一行没有类别...

google-app-engine webapp2

4
推荐指数
1
解决办法
2490
查看次数

标签 统计

google-app-engine ×1

webapp2 ×1