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

Side by Side Diff: chrome/browser/prerender/tools/prerender_test_server/prerender_test_server.py

Issue 2257523002: prerender_test_server.py: bind to loopback interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 2016 The Chromium Authors. All rights reserved. 2 # Copyright 2016 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 # A local web server with a copy of functionality of 6 # A local web server with a copy of functionality of
7 # http://prerender-test.appspot.com with a DISABLED check whether Prerendering 7 # http://prerender-test.appspot.com with a DISABLED check whether Prerendering
8 # is working. 8 # is working.
9 9
10 import BaseHTTPServer 10 import BaseHTTPServer
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 self.send_response(200) 47 self.send_response(200)
48 self.send_header('Content-type', mime_type) 48 self.send_header('Content-type', mime_type)
49 self.send_header('Cache-Control', 'no-cache') 49 self.send_header('Cache-Control', 'no-cache')
50 self.end_headers() 50 self.end_headers()
51 51
52 def main(argv): 52 def main(argv):
53 parser = argparse.ArgumentParser(prog='prerender_test') 53 parser = argparse.ArgumentParser(prog='prerender_test')
54 parser.add_argument('-p', '--port', type=int, default=8080, 54 parser.add_argument('-p', '--port', type=int, default=8080,
55 help='port to run on (default = %(default)s)') 55 help='port to run on (default = %(default)s)')
56 args = parser.parse_args(argv) 56 args = parser.parse_args(argv)
57 server_name = 'localhost'
57 58
58 s = BaseHTTPServer.HTTPServer(('', args.port), Handler) 59 s = BaseHTTPServer.HTTPServer((server_name, args.port), Handler)
59 try: 60 try:
60 print("Listening on http://localhost:%d/" % args.port) 61 print('Listening on http://{}:{}/'.format(server_name, args.port))
61 s.serve_forever() 62 s.serve_forever()
62 return 0 63 return 0
63 except KeyboardInterrupt: 64 except KeyboardInterrupt:
64 s.server_close() 65 s.server_close()
65 return 130 66 return 130
66 67
67 68
68 if __name__ == '__main__': 69 if __name__ == '__main__':
69 sys.exit(main(sys.argv[1:])) 70 sys.exit(main(sys.argv[1:]))
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