diff options
author | Guido van Rossum <guido@python.org> | 2001-01-14 23:21:25 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-01-14 23:21:25 (GMT) |
commit | 077153e9738466a9b0d3b47eebc648759e130803 (patch) | |
tree | 108dc85542a55e8e96d52818ee10e25fc44392be /Lib/SimpleHTTPServer.py | |
parent | 2d3eb133b7b66408ee7abf182101dbdc3358b8d9 (diff) | |
download | cpython-077153e9738466a9b0d3b47eebc648759e130803.zip cpython-077153e9738466a9b0d3b47eebc648759e130803.tar.gz cpython-077153e9738466a9b0d3b47eebc648759e130803.tar.bz2 |
- Use mimetypes.types_map to initialize extensions_map.
- 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 :-).
Diffstat (limited to 'Lib/SimpleHTTPServer.py')
-rw-r--r-- | Lib/SimpleHTTPServer.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/SimpleHTTPServer.py b/Lib/SimpleHTTPServer.py index 4cfedbc..37e3b38 100644 --- a/Lib/SimpleHTTPServer.py +++ b/Lib/SimpleHTTPServer.py @@ -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, |