diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2012-11-14 11:49:55 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2012-11-14 11:49:55 (GMT) |
commit | 4115e99002f1c5a834b6365db4869bba7793a0f5 (patch) | |
tree | 00bfe3f00c302a14f142eb5042f73386b73176c7 /sugar_network/toolkit/router.py | |
parent | bbded279edeb6d058a80fc7204021c771e32938e (diff) |
Return meaning MIME type for routed static files
Diffstat (limited to 'sugar_network/toolkit/router.py')
-rw-r--r-- | sugar_network/toolkit/router.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sugar_network/toolkit/router.py b/sugar_network/toolkit/router.py index d224294..3861e1a 100644 --- a/sugar_network/toolkit/router.py +++ b/sugar_network/toolkit/router.py @@ -98,7 +98,6 @@ class Request(ad.Request): principal = None mountpoint = None - content_type = None if_modified_since = None @@ -157,7 +156,8 @@ class Router(object): request.principal = self.authenticate(request) if request.path[:1] == ['static']: - result = ad.PropertyMeta(path=join(static.PATH, *request.path[1:])) + path = join(static.PATH, *request.path[1:]) + result = ad.PropertyMeta(path=path, mime_type=_get_mime_type(path)) else: rout = self._routes.get(( request['method'], @@ -452,3 +452,12 @@ def _parse_accept_language(accept_language): langs.insert(len(langs) - index, lang) return langs + + +def _get_mime_type(path): + if path.endswith('.png'): + return 'image/png' + elif path.endswith('.svg'): + return 'image/svg+xml' + elif path.endswith('.ico'): + return 'image/x-icon' |