python - Flask 只能看到使用 curl 发送的多个参数中的第一个参数

标签 python flask

我正在使用 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&param2=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&param2=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/

相关文章:

Python 将命令及其输出写入文件

python - 更新数据存储中的 div 页面坐标

python - 知道 pickle.dump 中的 "OSError: [Errno 22] Invalid argument"吗?

python - SQLAlchemy 告诉我 "AttributeError: type object ' User' 没有属性 'columns' "

python - 使用 python 的网络服务器

python - 在Python3.6上运行的Flask找不到htmlentitydefs?

python - 每个 Flask session 存储大数据或服务连接

python - pandas read_excel(sheet name = None) 返回一个字符串字典,而不是数据框?

python - selenium python 元素从下拉菜单中选择

python - 添加到 .css 文件的新 CSS 选择器不起作用;使用 Flask 和 Bootstrap