I am creating a download service using the python requests library (See here) to download data from another server. The problem is that sometimes I get a 503 error
and I need to display an appropriate message. See sample code below:
import requests
s = requests.Session()
response = s.get('http://mycustomserver.org/download')
I can check from response.status_code
and get the status code = 200
.
But how do I try/catch
for a specific error, in this case, I want to be able to detect 503 error
and handle them appropriately.
How do I do that?