I have a problem with POST request with Python/Django and Minio server, this is the code
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)
The problem is that the request won't work if I don't remove the import at the beginning and I can't understand why. This is the error generated:
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',))
and this is the script that make the request is this one:
.... some code....
try:
r = requests.post("http://myurl:8001/mypath/", data=my_data, timeout=1)
except Exception as e:
print(e)
I've already tried to increase the timeout but it's not working and of course, I've tested the Minio part in another script, the import it's generating this error only in this request script.
Thanks for the help