我试图通过post请求在python flask端点中接收一个文件,然后将其发送到另一个端点。我在API上收到一个文件,但我不知道如何包装它以备下次请求。你知道吗
代码如下所示
@app.route('/file', methods=['POST'])
def get_task_file():
response_obj = {}
if 'file' not in request.files:
abort(400)
print(request.files["file"].filename)
# TEXT EXTRACT
url1 = 'http://localhost:5001/text/api'
headers = {'Content-type': 'multipart/form-data'}
print(type(request.files['file']))
r1 = requests.request("POST", url1, files={'file':request.files['file']}, headers=headers)
print(r1.text)
现在文件类型是<class 'werkzeug.datastructures.FileStorage'>
,我得到400个错误。我只想补充一点,第二个API上的逻辑是相似的,我应该更改它吗?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐