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

Side by Side Diff: mojo/devtools/common/devtoolslib/http_server.py

Issue 1157993010: Add --sky support in mojo_shell.py. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 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 | mojo/tools/mojo_shell.py » ('j') | mojo/tools/mojo_shell.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import atexit 5 import atexit
6 import datetime 6 import datetime
7 import email.utils 7 import email.utils
8 import hashlib 8 import hashlib
9 import logging 9 import logging
10 import math 10 import math
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 SimpleHTTPServer.SimpleHTTPRequestHandler.translate_path(self, path)) 133 SimpleHTTPServer.SimpleHTTPRequestHandler.translate_path(self, path))
134 134
135 for prefix, local_base_path in mappings: 135 for prefix, local_base_path in mappings:
136 if normalized_path.startswith(prefix): 136 if normalized_path.startswith(prefix):
137 return os.path.join(local_base_path, normalized_path[len(prefix):]) 137 return os.path.join(local_base_path, normalized_path[len(prefix):])
138 138
139 # This class is only used internally, and we're adding a catch-all '' 139 # This class is only used internally, and we're adding a catch-all ''
140 # prefix at the end of |mappings|. 140 # prefix at the end of |mappings|.
141 assert False 141 assert False
142 142
143 def guess_type(self, path):
144 if path.endswith('.dart'):
145 return 'application/dart'
146 elif path.endswith('.sky'):
147 return 'text/sky'
148 return SimpleHTTPServer.SimpleHTTPRequestHandler.guess_type(self, path)
149
143 def log_message(self, *_): 150 def log_message(self, *_):
144 """Override the base class method to disable logging.""" 151 """Override the base class method to disable logging."""
145 pass 152 pass
146 153
147 RequestHandler.protocol_version = 'HTTP/1.1' 154 RequestHandler.protocol_version = 'HTTP/1.1'
148 return RequestHandler 155 return RequestHandler
149 156
150 157
151 def StartHttpServer(local_dir_path, host_port=0, additional_mappings=None): 158 def StartHttpServer(local_dir_path, host_port=0, additional_mappings=None):
152 """Starts an http server serving files from |local_dir_path| on |host_port|. 159 """Starts an http server serving files from |local_dir_path| on |host_port|.
(...skipping 15 matching lines...) Expand all
168 mappings.append(('', local_dir_path)) 175 mappings.append(('', local_dir_path))
169 handler_class = _GetHandlerClassForPath(mappings) 176 handler_class = _GetHandlerClassForPath(mappings)
170 177
171 httpd = _SilentTCPServer(('127.0.0.1', host_port), handler_class) 178 httpd = _SilentTCPServer(('127.0.0.1', host_port), handler_class)
172 atexit.register(httpd.shutdown) 179 atexit.register(httpd.shutdown)
173 180
174 http_thread = threading.Thread(target=httpd.serve_forever) 181 http_thread = threading.Thread(target=httpd.serve_forever)
175 http_thread.daemon = True 182 http_thread.daemon = True
176 http_thread.start() 183 http_thread.start()
177 return httpd.server_address 184 return httpd.server_address
OLDNEW
« no previous file with comments | « no previous file | mojo/tools/mojo_shell.py » ('j') | mojo/tools/mojo_shell.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698