P
P
Pavel Litvinenko2015-07-29 20:37:27
RESTful API
Pavel Litvinenko, 2015-07-29 20:37:27

How to make a POST request on the server side using python?

Good evening. I'm trying to send a post request from my flask app to the rest api of the thumbor server. For some unknown reason, the request that I send from the flask application does not reach, and the application crashes with an exception:
requests.exceptions.ConnectionError: ('Connection aborted.', TimeoutError(110, 'Connection timed out'))
Tried to run a small server-side test script, everything works fine

endpoint = ' thumbor.sitename.com/image '
filename = './test.jpg'
with open(filename, 'rb') as media_file:
files = { 'media': media_file.read() }
response = requests.post(endpoint, files=files)
print(response, response.headers['location'])

The code which in the application practically does not differ from the test one. I also tried to send a request to another rest api, the result is about the same (falls with TimeoutError).
flask application, thumbor server and other api are on the same server in different docker containers.
Where can I find the cause of this problem?

EDIT:
I tried to run the test inside a docker container, the circle is closed, apparently it's all about the container settings. There is a suspicion that the whole thing is in closed ports, but what remains a mystery to me ...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2015-07-29
@sim3x

www.stackoverflow.com/a/10313115

U
un1t, 2015-07-29
@un1t

so it would not be bad to show an error
endpoint = 'thumbor.sitename.com/image'
seems to have forgotten 'http://'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question