summaryrefslogtreecommitdiffstats
path: root/scripts/minimaws/lib/wsgiserve.py
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-09-23 17:03:20 +1000
committer Vas Crabb <vas@vastheman.com>2021-09-23 17:03:20 +1000
commitd35ff4bca69175bb6909722379298c17ae2f0989 (patch)
tree8ad8ae2c0c4675f6a7e43126b48c00f53fb90459 /scripts/minimaws/lib/wsgiserve.py
parent5c447ee7229c17b60c25b4513976068176d39590 (diff)
-minimaws: Made table sort widgets (and the code behind them) less ugly.
-util/delegate.cpp: Added a couple of comments about assumptions.
Diffstat (limited to 'scripts/minimaws/lib/wsgiserve.py')
-rw-r--r--scripts/minimaws/lib/wsgiserve.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/scripts/minimaws/lib/wsgiserve.py b/scripts/minimaws/lib/wsgiserve.py
index 0a5cda4f762..26e7d523904 100644
--- a/scripts/minimaws/lib/wsgiserve.py
+++ b/scripts/minimaws/lib/wsgiserve.py
@@ -67,6 +67,8 @@ class ErrorPageHandler(HandlerBase):
class AssetHandler(HandlerBase):
+ EXTENSIONMAP = { '.js': 'application/javascript', '.svg': 'image/svg+xml' }
+
def __init__(self, directory, app, application_uri, environ, start_response, **kwargs):
super(AssetHandler, self).__init__(app=app, application_uri=application_uri, environ=environ, start_response=start_response, **kwargs)
self.directory = directory
@@ -90,8 +92,11 @@ class AssetHandler(HandlerBase):
else:
try:
f = open(path, 'rb')
- type, encoding = mimetypes.guess_type(path)
- self.start_response('200 OK', [('Content-type', type or 'application/octet-stream'), ('Cache-Control', 'public, max-age=3600')])
+ base, extension = os.path.splitext(path)
+ mimetype = self.EXTENSIONMAP.get(extension)
+ if mimetype is None:
+ mimetype, encoding = mimetypes.guess_type(path)
+ self.start_response('200 OK', [('Content-type', mimetype or 'application/octet-stream'), ('Cache-Control', 'public, max-age=3600')])
return wsgiref.util.FileWrapper(f)
except:
self.start_response('500 %s' % (self.STATUS_MESSAGE[500], ), [('Content-type', 'text/html; charset=utf-8'), ('Cache-Control', 'public, max-age=3600')])