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

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

Issue 10545043: Extensions docs server: Design changes, partial template support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 8 years, 6 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
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 import logging
6
7 DOCS_PATH = 'docs/'
8 STATIC_PATH = DOCS_PATH + 'static/'
9
10 class ServerInstance(object):
not at google - send to devlin 2012/06/08 01:42:53 Comment?
cduvall 2012/06/08 02:18:06 Done.
11 def __init__(self, data_source, fetcher):
12 self._data_source = data_source
13 self._fetcher = fetcher
14
15 def Run(self, path, request_handler):
16 parts = path.split('/')
17 filename = parts[-1]
18 content = self._data_source.Render(filename, '{"test": "Hello"}')
19 if not content:
20 logging.info('Template not found for: ' + filename)
21 try:
22 result = self._fetcher.FetchResource(STATIC_PATH + filename)
23 for key in result.headers:
24 request_handler.response.headers[key] = result.headers[key]
25 content = result.content
26 except:
27 # TODO should be an actual not found page.
not at google - send to devlin 2012/06/08 01:42:53 Should make the response code 404, too. I presume
cduvall 2012/06/08 02:18:06 Done. Just checked and default is 200.
28 content = 'File not found.'
29 request_handler.response.out.write(content)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698