diff options
Diffstat (limited to 'subplot')
-rw-r--r-- | subplot/ewww.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/subplot/ewww.py b/subplot/ewww.py index e30c219..a6c4c4f 100644 --- a/subplot/ewww.py +++ b/subplot/ewww.py @@ -24,10 +24,10 @@ def _write(filename, content): # Construct a URL that points to server running on localhost by # replacing the actual scheme and host with ones that work for test. def _url(ctx, url): - port = ctx["config"]["port"] + listen = ctx["config"]["listen"] c = urllib.parse.urlparse(url) host = c[1] - c = (c[0], "localhost:{}".format(port)) + c[2:] + c = (c[0], "{}".format(listen)) + c[2:] return urllib.parse.urlunparse(c), host @@ -64,9 +64,11 @@ def start_server(ctx, filename=None): logging.debug(f"Starting ewww with config file {filename}") config = get_file(filename).decode("UTF-8") config = yaml.safe_load(config) - port = config["port"] = random.randint(2000, 30000) - logging.debug(f"Picked randomly port for ewww: {config['port']}") + port = random.randint(2000, 30000) + logging.debug(f"Picked randomly port for ewww: {port}") + config["listen"] = f"localhost:{port}" ctx["config"] = config + logging.debug(f"ewww config: {config!r}") config = yaml.safe_dump(config) _write(filename, config) |