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

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

Issue 10827138: Extension docs server: fix errors in preview.py. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: . Created 8 years, 4 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
« 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 #!/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 is a preview server for the apps and extensions docs. Navigate to a docs 6 # This is a preview server for the apps and extensions docs. Navigate to a docs
7 # page, and the page will be rendered how it will be on the production server. 7 # page, and the page will be rendered how it will be on the production server.
8 # 8 #
9 # For example: http://localhost:8000/tabs.html will render the docs page for 9 # For example: http://localhost:8000/tabs.html will render the docs page for
10 # the tabs API. 10 # the tabs API.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 content = response.out.getvalue() 48 content = response.out.getvalue()
49 if isinstance(content, str): 49 if isinstance(content, str):
50 self.wfile.write(content) 50 self.wfile.write(content)
51 else: 51 else:
52 self.wfile.write(content.encode('utf-8', 'replace')) 52 self.wfile.write(content.encode('utf-8', 'replace'))
53 53
54 if __name__ == '__main__': 54 if __name__ == '__main__':
55 parser = optparse.OptionParser( 55 parser = optparse.OptionParser(
56 description='Runs a server to preview the extension documentation.', 56 description='Runs a server to preview the extension documentation.',
57 usage='usage: %prog [option]...') 57 usage='usage: %prog [option]...')
58 parser.add_option('-p', '--port', default=8000, 58 parser.add_option('-p', '--port', default="8000",
59 help='port to run the server on') 59 help='port to run the server on')
60 60
61 (opts, argv) = parser.parse_args() 61 (opts, argv) = parser.parse_args()
62 62
63 print('Starting previewserver on port %s' % opts.port)
64 print('The extension documentation can be found at:')
65 print('')
66 print(' http://localhost:%s' % opts.port)
67 print('')
68
69 server = HTTPServer(('', int(opts.port)), RequestHandler)
63 try: 70 try:
64 print('Starting previewserver on port %d' % opts.port)
65 print('The extension documentation can be found at:')
66 print('')
67 print(' http://localhost:%d' % opts.port)
68 print('')
69
70 server = HTTPServer(('', int(opts.port)), RequestHandler)
71 server.serve_forever() 71 server.serve_forever()
72 except KeyboardInterrupt: 72 except KeyboardInterrupt:
73 pass 73 pass
74 finally: 74 finally:
75 server.socket.close() 75 server.socket.close()
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