python - Python 请求发送空数据
问题描述
我正在使用 python 的请求模块发送一个发布请求:
res = requests.post('https://mysite.xyz/bot/upload',
headers={'Content-type': 'text/plain'},
data=data.encode('utf8'),
verify=True)
这是我用https://httpbin.org/post替换 url 时得到的(预期的)响应:
{
"args": {},
"data": "test data",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Content-Length": "9",
"Content-Type": "text/plain",
"Host": "httpbin.org",
"User-Agent": "python-requests/2.20.1"
},
"json": null,
"origin": "<my IP address>, <my IP address>",
"url": "https://httpbin.org/post"
}
我发送数据的服务器使用烧瓶。这是代码:
@app.route('/bot/upload', methods=['POST', 'GET'])
def dataup():
data = flask.request.data
print(flask.request.content_type)
print(data)
# do stuff with it
这输出:
None
b''
出了什么问题?
解决方案
推荐阅读
- jquery - 仅使用一项功能显示多个时区
- python - Python statsmodel VARMAX 结果
- r - 在 R 脚本中选择了未定义的列
- python - 使用 numpy 清理和连接包含特殊字符的 2D 掩码字符串数组
- angular - 使用量角器在 GraphQL API 响应中测试数据
- css - CSS:有序列表中编号的垂直位置
- excel - 在两个特定工作表之间按字母顺序插入新工作表
- ssh - ssh permission denied when prefixing with ssh protocol
- azure - How to redirect traffic hosted on an azure endpoint (DNS/static IP) to different external IP address
- download - ionic4/Angular7 - Property 'dataDirectory' does not exist on type 'File'