Flask只看到与cu一起发送的多个参数中的第一个参数

2024-05-11 22:48:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用curl请求一个需要多个查询参数的Flask路由。但是,日志只显示url中的第一个参数,而Flask没有看到第二个参数。出什么问题了?在

@app.route('/path', methods=['GET'])
def foo():
    print request.args.get('param2')
    req = request.args.items()
    print req
^{pr2}$
127.0.0.1 - - [01/Jun/2015 21:35:10] "GET /path?param1=1 HTTP/1.1" 200 -
None
[('param1', u'1')]

Tags: pathappurlflask路由参数getrequest
1条回答
网友
1楼 · 发布于 2024-05-11 22:48:26

请参阅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&param2=2" . In the shell, & is used for forking processes and doesn't behave like you would expect it to. – Bidhan A

相关问题 更多 >