【问题标题】:Handling URLs containing slash '/' character with web.py使用 web.py 处理包含斜杠“/”字符的 URL
【发布时间】:2012-12-19 20:21:58
【问题描述】:

我来自 Flask,处理带有斜杠字符的 URL 非常简洁:http://flask.pocoo.org/snippets/76/

我现在正在使用 web.py,我也想这样做。我事先不知道网址会有多少个斜线。 有什么想法吗?

【问题讨论】:

    标签: python url web.py slash


    【解决方案1】:

    也许你可以只使用普通的:

    urls = (
        "/product/(.*)", product_handler
        )
    

    然后产品处理程序采用单个变量:

    class product_handler:
        def GET(self, url_string):
            url_pieces = url_string.split('/')
            # ...
    

    这样的?

    【讨论】:

      猜你喜欢
      • 2016-04-06
      • 2015-10-04
      • 2015-10-03
      • 2017-10-16
      • 2012-10-27
      • 1970-01-01
      • 1970-01-01
      • 2018-01-29
      • 2012-06-28
      相关资源
      最近更新 更多