OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
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 | |
4 # found in the LICENSE file. | |
5 import optparse | |
6 import os | |
7 import sys | |
8 | |
9 import SimpleHTTPServer | |
10 import BaseHTTPServer | |
11 | |
12 from build import calcdeps | |
13 | |
14 DEFAULT_PORT = 8003 | |
15 | |
16 class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
17 def do_GET(self): | |
18 if self.path == '/src/base/deps.js': | |
19 self.log_message('Regenerating deps') | |
20 calcdeps.regenerate_deps() | |
21 return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) | |
22 | |
23 class Server(BaseHTTPServer.HTTPServer): | |
24 def handle_one_request(self): | |
25 try: | |
26 HTTPServer.handle_one_request(self) | |
27 except KeyboardInterrupt: | |
28 sys.exit(255) | |
29 | |
30 def Main(args): | |
31 parser = optparse.OptionParser() | |
32 parser.add_option('--port', | |
33 action='store', | |
34 type='int', | |
35 default=DEFAULT_PORT, | |
36 help='Port to serve from') | |
37 options, args = parser.parse_args() | |
38 server = Server(('', options.port), Handler) | |
39 sys.stderr.write("Now running on http://localhost:%i\n" % options.port) | |
40 server.serve_forever() | |
41 | |
42 if __name__ == '__main__': | |
43 sys.exit(Main(sys.argv[1:])) | |
OLD | NEW |