Pages

Saturday 16 April 2016

Python SimpleHTTPServer does not serve SVG! [Solved]

                                                                          I was testing one of my web projects in mobile devices and i encountered this problem that it's not serving svg i generated using adobe illustrator! There is problem in mime types in current SimpleHTTPServer. So i'm posting code for a modified version of python SimpleHTTPServer that serve's SVG images :D



That's it. Enjoy!

EDIT => 26 October 2016

hey guys i was learning nginx webserver and i learned about mime-types there so i thought to add some more information here. MIME basically is shortform of Multi-Purpose Internet Mail Extensions. This is basically a file in nginx which has a list of two column values which contains extensions(pdf, svg, jpeg, png, mp3, mp4) and content-type(application/pdf, image/svg+xml etc ..) so if in the servers mime-types file there is no mentioned extention with content-type then its defaults to content-type: application/octet-stream. So in the above case python SimpleHTTPServer does not has extension svg and corresponding content-type: application/svg+xml in its mime-types file that's why its defaults to content-type: application/octet-stream and instead of rendering in browser it downloads.

1 comment:

  1. Super Vectorizer automatically converts PNG files to SVG graphics on Mac and make the svg results easier to edit and adjust. Image Vectorizer Mac

    ReplyDelete