OLD | NEW |
---|---|
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. |
11 # | 11 # |
12 # Run with: './preview.py' | 12 # Run with: './preview.py' |
13 | 13 |
14 from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer | 14 from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer |
15 import optparse | 15 import optparse |
16 import os | 16 import os |
17 import shutil | |
17 from StringIO import StringIO | 18 from StringIO import StringIO |
18 import sys | 19 import sys |
19 import urlparse | 20 import urlparse |
20 | 21 |
22 import build_server | |
23 build_server.main() | |
not at google - send to devlin
2012/08/02 19:49:07
comment plz
cduvall
2012/08/02 19:52:08
Done.
| |
21 from handler import Handler | 24 from handler import Handler |
22 | 25 |
23 class Response(object): | 26 class Response(object): |
24 def __init__(self): | 27 def __init__(self): |
25 self.status = 200 | 28 self.status = 200 |
26 self.out = StringIO() | 29 self.out = StringIO() |
27 self.headers = {} | 30 self.headers = {} |
28 | 31 |
29 def set_status(self, status): | 32 def set_status(self, status): |
30 self.status = status | 33 self.status = status |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 print('The extension documentation can be found at:') | 67 print('The extension documentation can be found at:') |
65 print('') | 68 print('') |
66 print(' http://localhost:%s' % opts.port) | 69 print(' http://localhost:%s' % opts.port) |
67 print('') | 70 print('') |
68 | 71 |
69 server = HTTPServer(('', int(opts.port)), RequestHandler) | 72 server = HTTPServer(('', int(opts.port)), RequestHandler) |
70 try: | 73 try: |
71 server.serve_forever() | 74 server.serve_forever() |
72 finally: | 75 finally: |
73 server.socket.close() | 76 server.socket.close() |
77 shutil.rmtree(os.path.join(sys.argv[0].rsplit(os.sep, 1)[0], 'third_party')) | |
OLD | NEW |