我正在使用 curl 向需要多个查询参数的 Flask 路由发出请求。但是,日志仅显示 url 中的第一个参数,而 Flask 看不到第二个参数。出了什么问题?
@app.route('/path', methods=['GET'])
def foo():
print request.args.get('param2')
req = request.args.items()
print req
curl http://localhost:5000/path?param1=1¶m2=2
127.0.0.1 - - [01/Jun/2015 21:35:10] "GET /path?param1=1 HTTP/1.1" 200 -
None
[('param1', u'1')]
最佳答案
查看 Bidhan 的评论 here .我在使用 curl
时没有将我的 URL 放在双引号内。
引用:
If you're using curl then you need to pass the url inside of quotes. It should look like
curl "localhost:5000/path?param1=1¶m2=2"
. In the shell, & is used for forking processes and doesn't behave like you would expect it to. – Bidhan A
关于python - Flask 只能看到使用 curl 发送的多个参数中的第一个参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30586601/