【发布时间】:2021-05-27 02:05:05
【问题描述】:
我正在尝试使用 curl 上传包含一些数据的泡菜文件。我用了这个命令
curl -i -X POST -H 'Content-Type: application/json' -F 'data=@/example_data.p' http://localhost:9999/process
这是我在 /process 上的内容
@app.route('/process', methods=['GET', 'POST'])
def process():
if request.method == 'POST':
d = request.get_json()
p = dict(d['payload'])
print(p.keys())
# print(p)
gid = uuid.uuid4()
Q.put({'gid': gid, 'payload': p})
print(gid)
r = {"id": str(gid)}
response = app.response_class(response=json.dumps(
r), status=200, mimetype='application/json')
return response
if __name__ == "__main__":
main()
这是我遇到的错误
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 904k 100 192 100 904k 901 4245k --:--:-- --:--:-- --:--:-- 4266kHTTP/1.0 400 BAD REQUEST
Content-Type: text/html; charset=utf-8
Content-Length: 192
Access-Control-Allow-Origin: *
Server: Werkzeug/2.0.0 Python/3.7.8
Date: Thu, 27 May 2021 01:56:00 GMT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>The browser (or proxy) sent a request that this server could not understand.</p>
谁能解释一下这个问题?
【问题讨论】:
标签: python python-3.x flask curl pickle