Last active
May 9, 2016 17:47
-
-
Save KennethWilke/cb0de8ac9743bf74dad007ce9c3cdbad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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