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

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: 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
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..2d57d8932425cd93b40125fc6e428d10ae731061 100644
--- a/mojo/devtools/common/devtoolslib/http_server.py
+++ b/mojo/devtools/common/devtoolslib/http_server.py
@@ -126,12 +126,13 @@ def _GetHandlerClassForPath(base_path):
return RequestHandler
-def StartHttpServer(path):
+def StartHttpServer(local_dir_path, host_port=0):
"""Starts an http server serving files from |path| on random
(system-allocated) port. Returns the server address.
"""
- 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)

Powered by Google App Engine
This is Rietveld 408576698