Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: chrome/common/extensions/docs/server2/server_instance.py

Issue 10911301: Extensions Docs Server: 404 on URLs like developer.chrome.com/extensions/storage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from fnmatch import fnmatch 5 from fnmatch import fnmatch
6 import mimetypes 6 import mimetypes
7 import os 7 import os
8 8
9 from file_system import FileNotFoundError 9 from file_system import FileNotFoundError
10 import compiled_file_system as compiled_fs 10 import compiled_file_system as compiled_fs
(...skipping 22 matching lines...) Expand all
33 except FileNotFoundError: 33 except FileNotFoundError:
34 return None 34 return None
35 base, ext = os.path.splitext(path) 35 base, ext = os.path.splitext(path)
36 response.headers['content-type'] = mimetypes.types_map[ext] 36 response.headers['content-type'] = mimetypes.types_map[ext]
37 return result 37 return result
38 38
39 def Get(self, path, request, response): 39 def Get(self, path, request, response):
40 # TODO(cduvall): bundle up all the request-scoped data into a single object. 40 # TODO(cduvall): bundle up all the request-scoped data into a single object.
41 templates = self._template_data_source_factory.Create(request, path) 41 templates = self._template_data_source_factory.Create(request, path)
42 42
43 content = None
43 if fnmatch(path, 'extensions/examples/*.zip'): 44 if fnmatch(path, 'extensions/examples/*.zip'):
44 content = self._example_zipper.Create( 45 content = self._example_zipper.Create(
45 path[len('extensions/'):-len('.zip')]) 46 path[len('extensions/'):-len('.zip')])
46 response.headers['content-type'] = mimetypes.types_map['.zip'] 47 response.headers['content-type'] = mimetypes.types_map['.zip']
47 elif path.startswith('extensions/examples/'): 48 elif path.startswith('extensions/examples/'):
48 content = self._cache.GetFromFile( 49 content = self._cache.GetFromFile(
49 DOCS_PATH + '/' + path[len('extensions/'):]) 50 DOCS_PATH + '/' + path[len('extensions/'):])
50 response.headers['content-type'] = 'text/plain' 51 response.headers['content-type'] = 'text/plain'
51 elif path.startswith('static/'): 52 elif path.startswith('static/'):
52 content = self._FetchStaticResource(path, response) 53 content = self._FetchStaticResource(path, response)
53 else: 54 elif path.endswith('.html'):
54 content = templates.Render(path) 55 content = templates.Render(path)
55 56
56 response.headers['x-frame-options'] = 'sameorigin' 57 response.headers['x-frame-options'] = 'sameorigin'
57 if content: 58 if content:
58 response.headers['cache-control'] = 'max-age=300' 59 response.headers['cache-control'] = 'max-age=300'
59 response.out.write(content) 60 response.out.write(content)
60 else: 61 else:
61 response.set_status(404); 62 response.set_status(404);
62 response.out.write(templates.Render('404')) 63 response.out.write(templates.Render('404'))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698