我对 Python/Django 和 Minio 服务器的 POST 请求有疑问,这是代码
from django.http import HttpResponse
import json
from minio import Minio
minioClient = Minio('mypath:9000',
access_key='mykey',
secret_key='mysecret',
secure=False)
def getMessage(request):
if request.method == 'POST':
data = json.loads(request.body.decode('utf-8'))
for obj in data['files']:
...do some stuff....
minioClient.fget_object(myvar, myvar2, '/tmp/processing')
return HttpResponse(file)
问题是,如果我一开始不删除导入,请求将不起作用,我不明白为什么。这是生成的错误:
HTTPConnectionPool(host='myhost', port=8001):
Max retries exceeded with url: /myurl/
(Caused NewConnectionError
('<requests.packages.urllib3.connection.HTTPConnection object at 0x7fcbeab21160>:
Failed to establish a new connection: [Errno 111] Connection refused',))
这是发出请求的脚本:
.... some code....
try:
r = requests.post("http://myurl:8001/mypath/", data=my_data, timeout=1)
except Exception as e:
print(e)
我已经尝试增加超时但它不起作用,当然,我已经在另一个脚本中测试了 Minio 部分,导入它仅在此请求脚本中生成此错误。
谢谢您的帮助