]> granicus.if.org Git - python/commitdiff
- Use mimetypes.types_map to initialize extensions_map.
authorGuido van Rossum <guido@python.org>
Sun, 14 Jan 2001 23:21:25 +0000 (23:21 +0000)
committerGuido van Rossum <guido@python.org>
Sun, 14 Jan 2001 23:21:25 +0000 (23:21 +0000)
- Change the default file type to application/octet-stream.
- Add support to recognize .py, .c, .h files as text/plain (this is
  what I use most :-).

Lib/SimpleHTTPServer.py

index 4cfedbc9fe9ba8b1962fee713d163f4f6039ec2a..37e3b38dfabdee90e3dc7a52395458389dcf4eb7 100644 (file)
@@ -6,7 +6,7 @@ and HEAD requests in a fairly straightforward manner.
 """
 
 
-__version__ = "0.5"
+__version__ = "0.6"
 
 
 import os
@@ -16,6 +16,7 @@ import BaseHTTPServer
 import urllib
 import cgi
 import shutil
+import mimetypes
 from StringIO import StringIO
 
 
@@ -179,14 +180,13 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
         else:
             return self.extensions_map['']
 
-    extensions_map = {
-            '': 'text/plain',   # Default, *must* be present
-            '.html': 'text/html',
-            '.htm': 'text/html',
-            '.gif': 'image/gif',
-            '.jpg': 'image/jpeg',
-            '.jpeg': 'image/jpeg',
-            }
+    extensions_map = mimetypes.types_map.copy()
+    extensions_map.update({
+        '': 'application/octet-stream', # Default
+        '.py': 'text/plain',
+        '.c': 'text/plain',
+        '.h': 'text/plain',
+        })
 
 
 def test(HandlerClass = SimpleHTTPRequestHandler,