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

Unified Diff: mojo/devtools/common/devtoolslib/http_server.py

Issue 1259763013: Devtools: add ServeLocalDirectories(). (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Add one more comment. Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/devtools/common/devtoolslib/android_shell.py ('k') | mojo/devtools/common/devtoolslib/linux_shell.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/devtools/common/devtoolslib/http_server.py
diff --git a/mojo/devtools/common/devtoolslib/http_server.py b/mojo/devtools/common/devtoolslib/http_server.py
index 5199f3ee116bb1b6eb051371700f3e2a07a3d6fa..4a5bd7505f4388e1e5cf66b9c4c56e55932d3076 100644
--- a/mojo/devtools/common/devtoolslib/http_server.py
+++ b/mojo/devtools/common/devtoolslib/http_server.py
@@ -171,24 +171,21 @@ def _GetHandlerClassForPath(mappings):
return RequestHandler
-def start_http_server(local_dir_path, host_port=0, additional_mappings=None):
+def start_http_server(mappings, host_port=0):
"""Starts an http server serving files from |local_dir_path| on |host_port|.
Args:
- local_dir_path: Path to the local filesystem directory to be served over
- http under.
+ mappings: List of tuples (prefix, local_base_path) mapping
+ URLs that start with |prefix| to local directory at |local_base_path|.
+ The prefixes should skip the leading slash. The first matching prefix
+ will be used each time.
host_port: Port on the host machine to run the server on. Pass 0 to use a
system-assigned port.
- additional_mappings: List of tuples (prefix, local_base_path) mapping
- URLs that start with |prefix| to local directory at |local_base_path|.
- The prefixes should skip the leading slash.
Returns:
Tuple of the server address and the port on which it runs.
"""
- assert local_dir_path
- mappings = additional_mappings if additional_mappings else []
- mappings.append(('', local_dir_path))
+ assert mappings
handler_class = _GetHandlerClassForPath(mappings)
try:
@@ -200,12 +197,12 @@ def start_http_server(local_dir_path, host_port=0, additional_mappings=None):
http_thread.start()
print 'Started http://%s:%d to host %s.' % (httpd.server_address[0],
httpd.server_address[1],
- local_dir_path)
+ str(mappings))
return httpd.server_address
except socket.error as v:
error_code = v[0]
print 'Failed to start http server for %s on port %d: %s.' % (
- local_dir_path, host_port, os.strerror(error_code))
+ str(mappings), host_port, os.strerror(error_code))
if error_code == errno.EADDRINUSE:
print (' Run `fuser %d/tcp` to find out which process is using the port.'
% host_port)
« no previous file with comments | « mojo/devtools/common/devtoolslib/android_shell.py ('k') | mojo/devtools/common/devtoolslib/linux_shell.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698