| OLD | NEW |
| 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 Loading... |
| 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:])) |
| OLD | NEW |