How do I serve a static SVG file with Flask?

Viewed 4450

I want to serve a static SVG file with Flask, but the SVG file is transferred without a Content-Type header. The correct mime type is image/svg+xml. How can I make sure that Flask uses the correct mime type for the SVG file and sends it to the browser?

I refer to the file as /static/python.svg, and it does exist.

I tried this in my __init__.py file, but it didn't make any difference:

import mimetypes

mimetypes.add_type('images/svg+xml', '.svg')
2 Answers
Related