Posterous theme by Cory Watilo

SimpleHTTPServer with PNG support

A simple python script to serve up the contents of the local directory and provide the correct mime-type (on Windows) for PNG files to use the browser to render the image:

 

import SimpleHTTPServer
import SocketServer


PORT = 8000
IP = SocketServer.socket.gethostbyname(SocketServer.socket.gethostname())

Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
Handler.extensions_map = {
".png":"image/png",
'': 'application/octet-stream',
}

httpd = SocketServer.TCPServer(("", PORT), Handler)

print "serving at port", PORT, "on", IP
httpd.serve_forever()