title: python request error handling
body: <p>I am writing some small python app which uses requests to get and post data to an html page.</p>
  
  <p>now the problem I am having is that if I can't reach the html page the code stops with a max retries exceeded. I want to be able to do some things if I can't reach the server.</p>
  
  <p>is such a thing possible?</p>
  
  <p>here is sample code:</p>
  
  <pre><code>import requests
  
  url = "http://127.0.0.1/"
  req = requests.get(url)
  if req.status_code == 304:
      #do something
  elif req.status_code == 404:
      #do something else
  # etc etc 
  
  # code here if server can`t be reached for whatever reason
  </code></pre>