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

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

Issue 218363002: Docs: Use ETags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 8 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
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # This helps you preview the apps and extensions docs. 6 # This helps you preview the apps and extensions docs.
7 # 7 #
8 # ./preview.py --help 8 # ./preview.py --help
9 # 9 #
10 # There are two modes: server- and render- mode. The default is server, in which 10 # There are two modes: server- and render- mode. The default is server, in which
(...skipping 29 matching lines...) Expand all
40 class _RequestHandler(BaseHTTPRequestHandler): 40 class _RequestHandler(BaseHTTPRequestHandler):
41 '''A HTTPRequestHandler that outputs the docs page generated by Handler. 41 '''A HTTPRequestHandler that outputs the docs page generated by Handler.
42 ''' 42 '''
43 def do_GET(self): 43 def do_GET(self):
44 # Rewrite paths that would otherwise be served from app.yaml. 44 # Rewrite paths that would otherwise be served from app.yaml.
45 self.path = { 45 self.path = {
46 '/robots.txt': '../../server2/robots.txt', 46 '/robots.txt': '../../server2/robots.txt',
47 '/favicon.ico': '../../server2/chrome-32.ico', 47 '/favicon.ico': '../../server2/chrome-32.ico',
48 '/apple-touch-icon-precomposed.png': '../../server2/chrome-128.png' 48 '/apple-touch-icon-precomposed.png': '../../server2/chrome-128.png'
49 }.get(self.path, self.path) 49 }.get(self.path, self.path)
50 response = LocalRenderer.Render(self.path) 50 response = LocalRenderer.Render(self.path, headers=dict(self.headers))
51 self.protocol_version = 'HTTP/1.1'
51 self.send_response(response.status) 52 self.send_response(response.status)
52 for k, v in response.headers.iteritems(): 53 for k, v in response.headers.iteritems():
53 self.send_header(k, v) 54 self.send_header(k, v)
54 self.end_headers() 55 self.end_headers()
55 self.wfile.write(response.content.ToString()) 56 self.wfile.write(response.content.ToString())
56 57
57 if __name__ == '__main__': 58 if __name__ == '__main__':
58 parser = optparse.OptionParser( 59 parser = optparse.OptionParser(
59 description='Runs a server to preview the extension documentation.', 60 description='Runs a server to preview the extension documentation.',
60 usage='usage: %prog [option]...') 61 usage='usage: %prog [option]...')
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 print('') 106 print('')
106 print(' http://localhost:%s/apps/' % opts.port) 107 print(' http://localhost:%s/apps/' % opts.port)
107 print('') 108 print('')
108 109
109 logging.getLogger().setLevel(logging.INFO) 110 logging.getLogger().setLevel(logging.INFO)
110 server = HTTPServer(('', int(opts.port)), _RequestHandler) 111 server = HTTPServer(('', int(opts.port)), _RequestHandler)
111 try: 112 try:
112 server.serve_forever() 113 server.serve_forever()
113 finally: 114 finally:
114 server.socket.close() 115 server.socket.close()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/patch_servlet_test.py ('k') | chrome/common/extensions/docs/server2/render_servlet.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698