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

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

Issue 1139053005: Add ServeLocalDirectory to the shell abstraction. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address Ben's comments. Created 5 years, 7 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 012a3f4f5943d5d711e166b2c806fd1ea143016e..edaaf061e23595275d54bb334bdf8598ca85a7fc 100644
--- a/mojo/devtools/common/devtoolslib/http_server.py
+++ b/mojo/devtools/common/devtoolslib/http_server.py
@@ -126,12 +126,16 @@ def _GetHandlerClassForPath(base_path):
return RequestHandler
-def StartHttpServer(path):
- """Starts an http server serving files from |path| on random
- (system-allocated) port. Returns the server address.
+def StartHttpServer(local_dir_path, host_port=0):
+ """Starts an http server serving files from |path| on |host_port|. Pass 0
+ as |host_port| to use a system-allocated port.
+
+ Returns:
+ Tuple of the server address and the port on which it runs.
"""
- assert path
- httpd = _SilentTCPServer(('127.0.0.1', 0), _GetHandlerClassForPath(path))
+ assert local_dir_path
+ httpd = _SilentTCPServer(('127.0.0.1', host_port),
+ _GetHandlerClassForPath(local_dir_path))
atexit.register(httpd.shutdown)
http_thread = threading.Thread(target=httpd.serve_forever)
« 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