svg support for app engine running python on windows xp

· App Engine, Python, SVG

While investigating app engine – svgz support (I’ll have a separate post for that) I encountered an even more basic issue: an app engine development server running on windows xp has no svg support at all. Every svg file referenced in a page is downloaded by the browser

A closer look revealed a wrong response header for the svg files – “Content-Type: application/octect-stream which leaves the browser with nothing to do but download it

The python run-time (C:\Python27\Lib\ has a “mime-type guessing” mechanism, which try to match the content-type by the file suffix , and return the general “application/octect-stream” for as a no-match. The guessing process checks against a “default list” and a local mapping dictionary. In windows only – the default list is populated from the machine’s registry, and windows-xp simply don’t have that svg type registed…

The solution is quite simple: add the line – ‘.svg’ : ‘image/svg+xml’ – to the dictionary in C:\Python27\Lib\ and restart your development server


Comments RSS
  1. Lindauson Hazell

    I’m doing some Windows-testing in Google App Engine (Python) with Django, and your solution to this problem is the best I’ve seen on the web. Thank you.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: