From d4b6c9d7150d7bd1960fe76dd9a1eda68e6cba75 Mon Sep 17 00:00:00 2001 From: Kevin Wojkovich Date: Wed, 25 Dec 2024 22:11:24 -0600 Subject: [PATCH] updates to the API and docs --- README.md | 9 ++++++++- server.py | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7920b74..5f743c8 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,13 @@ standard hosts file convention: `IP address Name` # Setup +## First-time Setup + +```sh +$ touch hosts +$ tr -dc A-Za-z0-9 tokens +``` + ## Python Application ```sh @@ -31,7 +38,7 @@ $ source .venv/bin/acticate $ pip install -r requirements.txt # run the application -$ flask run server.py --host 0.0.0.0 --port 8000 +$ fastapi run server.py --host 0.0.0.0 --port 8000 ``` ## Sudoers configuration diff --git a/server.py b/server.py index c59a706..96c4407 100644 --- a/server.py +++ b/server.py @@ -70,6 +70,7 @@ async def register_service(name: str, ip: str): registry[name] = [ip] update_hosts_file(registry) + reload_config() return registry @@ -82,8 +83,10 @@ async def register_service(name: str, ip: str): updated = [addr for addr in current if addr != ip] registry[name] = updated update_hosts_file(registry) + reload_config() return registry + @app.get("/service/{name}") async def read_service(name: str): """Reads the hosts file, produces a service catalog entry."""