【发布时间】:2017-04-03 07:58:37
【问题描述】:
我正在尝试从头开始通过烧瓶构建一个 cors 代理。这是我的代码
@app.route('/api/v1/cors/url=<name>&method=<method>', methods=['GET'])
def api_cors(name, method):
if method == 'http' or method == 'https':
r = request.urlopen(method+"://"+name)
return r.read()
else:
return "method not set!"
到目前为止它运行良好,但我有一个问题,当我通过“url=google.com&method=https”时它运行正常但是当我通过类似“url=google.com/images/image.jpg&method= https" "/" 将被视为一个新目录
在烧瓶中无论如何可以避免这个?
【问题讨论】:
-
您可以尝试将其放在引号之间,例如“url='google.com/images/image.jpg'&method=https”
-
@SunilT 我该怎么做,反正不会被绕过
-
请参考stackoverflow.com/questions/2992231/slashes-in-url-variables..似乎有多种解决方案可以解决这个问题。
标签: python python-3.x flask web-development-server