Reputation: 2988
I coded following simple http server in python, I have some files without an extension and want to serve them with "text/plain" mime type. How can I achieve it?
import SimpleHTTPServer
import SocketServer
PORT = 80
class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
pass
Handler.extensions_map['.shtml'] = 'text/html'
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "serving at port", PORT
httpd.serve_forever()
Upvotes: 0
Views: 2609
Reputation: 1395
According to the module's source code this should work:
Handler.extensions_map[''] = 'text/plain'
Upvotes: 4