From 3b7b8131a618bf7ad4aa8c5608a9853ae9539d3a Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 18 Sep 1995 21:50:43 +0000 Subject: [PATCH] recognize a few more file types --- Lib/SimpleHTTPServer.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Lib/SimpleHTTPServer.py b/Lib/SimpleHTTPServer.py index 67ec75afc86..dd3107abc6f 100644 --- a/Lib/SimpleHTTPServer.py +++ b/Lib/SimpleHTTPServer.py @@ -6,7 +6,7 @@ and HEAD requests in a fairly straightforward manner. """ -__version__ = "0.2" +__version__ = "0.3" import os @@ -141,6 +141,9 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): """ base, ext = posixpath.splitext(path) + if self.extensions_map.has_key(ext): + return self.extensions_map[ext] + ext = string.lower(ext) if self.extensions_map.has_key(ext): return self.extensions_map[ext] else: @@ -149,6 +152,10 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): extensions_map = { '': 'text/plain', # Default, *must* be present '.html': 'text/html', + '.htm': 'text/html', + '.gif': 'image/gif', + '.jpg': 'image/jpeg', + '.jpeg': 'image/jpeg', }