Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use mimetypes module instead of hand coded content types list

  • Loading branch information...
commit dc75b5db01f9c00c8f4a3f99a870000f43d7cb0c 1 parent 1ca7d91
@joelcarranza authored
Showing with 3 additions and 8 deletions.
  1. +3 −8 micropress/web.py
View
11 micropress/web.py
@@ -11,14 +11,9 @@
import os.path
from micropress import DEFAULT_PREVIEW_DIR
from micropress.util import mkdir
+import mimetypes
-content_type = dict(html="text/html",
- css='text/css',
- jpg='image/jpeg',
- xml='text/xml',
- png='image/png',
- js="text/javascript",
- ico='image/vnd.microsoft.icon')
+mimetypes.init()
def build(site,name):
# print "BUILD %s%s" % (path,ext)
@@ -45,7 +40,7 @@ def wsgifunc(site,environ, start_response):
if os.path.exists(path):
status = '200 OK'
# TODO: don't fail if we don't know content type!
- response_headers = [('Content-type',content_type[ext[1:]])]
+ response_headers = [('Content-type',mimetypes.types_map[ext])]
start_response(status, response_headers)
file = open(path,'rb')
# http://www.python.org/dev/peps/pep-0333/#optional-platform-specific-file-handling
Please sign in to comment.
Something went wrong with that request. Please try again.