Although you can run Python Simple HTTP Server by just typing:
It does not serve svg images with correct mime type. To add your own mime type for svg files, run it like this:
Make sure to use correct the location of python (#!/usr/bin/python).
python -m SimpleHTTPServer 8000
It does not serve svg images with correct mime type. To add your own mime type for svg files, run it like this:
#!/usr/bin/python
import SimpleHTTPServer
import SocketServer
import mimetypes
PORT = 8000
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
Handler.extensions_map['.svg']='image/svg+xml'
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "serving at port", PORT
httpd.serve_forever()
import SimpleHTTPServer
import SocketServer
import mimetypes
PORT = 8000
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
Handler.extensions_map['.svg']='image/svg+xml'
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "serving at port", PORT
httpd.serve_forever()
Make sure to use correct the location of python (#!/usr/bin/python).
7 comments:
Also if you need IPv6 support this page is useful:
http://www.righto.com/2011/02/ipv6-web-serving-with-arc-or-python.html
Thank you very much!
I have two comments:
- For python3 and on linux, #!/usr/bin/python3 is the correct text to put on the top of the program;
- That solution did not work for me, and when I look at Handler.extensions_map, I have a dictionary with a lot of extensions and mimetypes including svg. Then I don't understand the problem.
(I'm French, and my English level is bad)
I have a dictionary with a lot of extensions and mimetypes including svg. Then I don't understand the problem.
I Gratis APK
Baixar My APK
I have a dictionary with a lot of extensions and mimetypes including svg. Then I don't understand the problem.
Post a Comment