diff --git a/httpbin/core.py b/httpbin/core.py index 178f11b..0e12a51 100644 --- a/httpbin/core.py +++ b/httpbin/core.py @@ -657,11 +657,13 @@ def image(): headers = get_headers() if 'accept' not in headers: return image_png() # Default media type to png - + accept = headers['accept'].lower() if 'image/webp' in accept: return image_webp() + elif 'image/svg+xml' in accept: + return image_svg() elif 'image/jpeg' in accept: return image_jpeg() elif 'image/png' in accept or 'image/*' in accept: @@ -688,6 +690,12 @@ def image_webp(): return Response(data, headers={'Content-Type': 'image/webp'}) +@app.route('/image/svg') +def image_svg(): + data = resource('images/svg_logo.svg') + return Response(data, headers={'Content-Type': 'image/svg+xml'}) + + def resource(filename): path = os.path.join( tmpl_dir, diff --git a/httpbin/templates/images/svg_logo.svg b/httpbin/templates/images/svg_logo.svg new file mode 100644 index 0000000..e4b7e58 --- /dev/null +++ b/httpbin/templates/images/svg_logo.svg @@ -0,0 +1,259 @@ + + + SVG Logo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SVG + + + + + + + +