diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-07-22 11:19:57 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-07-22 13:05:58 +0300 |
commit | 16ba7070a6e040918f354b87f952cc47a7df6b5a (patch) | |
tree | 67c4fae0e8ebae013a962aba0614744ee7f16e37 /subplot | |
parent | dd6bf8292fbe53eac2c528ff613cd4420ba46655 (diff) | |
download | ewww-16ba7070a6e040918f354b87f952cc47a7df6b5a.tar.gz |
feat! allow/require setting address on which to listen
This will break all existing config file, of which there should be none.
Sponsored-by: author
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) |