Merge pull request #250 from phouse512/master

Added 406 unsupported media type response to /image
This commit is contained in:
Ian Cordasco
2015-09-17 11:36:43 -05:00
2 changed files with 16 additions and 1 deletions
+1 -1
View File
@@ -669,7 +669,7 @@ def image():
elif 'image/png' in accept or 'image/*' in accept:
return image_png()
else:
return status_code(404)
return status_code(406) # Unsupported media type
@app.route('/image/png')
+15
View File
@@ -54,6 +54,14 @@ ROBOT_TXT = """User-agent: *
Disallow: /deny
"""
ACCEPTED_MEDIA_TYPES = [
'image/webp',
'image/svg+xml',
'image/jpeg',
'image/png',
'image/*'
]
ANGRY_ASCII ="""
.-''''''-.
.' _ _ '.
@@ -209,6 +217,13 @@ def status_code(code):
'x-more-info': 'http://vimeo.com/22053820'
}
),
406: dict(data=json.dumps({
'message': 'Client did not request a supported media type.',
'accept': ACCEPTED_MEDIA_TYPES
}),
headers={
'Content-Type': 'application/json'
}),
407: dict(headers={'Proxy-Authenticate': 'Basic realm="Fake Realm"'}),
418: dict( # I'm a teapot!
data=ASCII_ART,