0

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()
Primoz
  • 1,324
  • 2
  • 16
  • 34
Sameera Kumarasingha
  • 2,908
  • 3
  • 25
  • 41

1 Answers1

3

According to the module's source code this should work:

Handler.extensions_map[''] = 'text/plain'
szatkus
  • 1,292
  • 6
  • 14