Skip to content

Instantly share code, notes, and snippets.

@KennethWilke
Last active May 9, 2016 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KennethWilke/cb0de8ac9743bf74dad007ce9c3cdbad to your computer and use it in GitHub Desktop.
Save KennethWilke/cb0de8ac9743bf74dad007ce9c3cdbad to your computer and use it in GitHub Desktop.
kwilke@kbawx:/tmp$ python test.py http://suchprogramming.com
ERROR: http://suchprogramming.com has content type "text/html; charset=UTF-8"
kwilke@kbawx:/tmp$ python test.py http://suchprogramming.com/wp-content/uploads/2016/03/parity.png
OK!
import sys
import requests
url = sys.argv[1]
response = requests.get(url)
content_type = response.headers['content-type']
if content_type == 'image/png':
print 'OK!'
else:
print 'ERROR: ' + url + ' has content type "' + content_type + '"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment