【问题标题】:WSGI : environ['QUERY_STRING'] parse something without a question mark?WSGI:environ['QUERY_STRING'] 解析没有问号的东西?
【发布时间】:2014-09-18 12:46:18
【问题描述】:

假设网址是:

 domain.tld/test?abc

这是脚本:

def application(environ, start_response):
    a = environ['QUERY_STRING']

    start_response('200 OK', [('Content-Type', 'text/html')])
    yield a

输出是:

abc

但问题是.. 可以“?”换成其他符号?

例如..

 domain.tld/test-abc

如果不使用 mod_rewrite 等,这是否可能?

【问题讨论】:

    标签: python apache python-2.7 mod-wsgi wsgi


    【解决方案1】:

    如果您使用的是像 Bottle 这样的框架,您可以编写路由处理程序来匹配您的请求 URL,例如:

    import bottle
    application=bottle.Bottle()
    @application.get('/test-<a>')
    def test(a):
        return a
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-16
      • 2013-07-26
      • 1970-01-01
      • 2014-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-07
      相关资源
      最近更新 更多