From 3696c9bfdb7a813419c8a53362260d59118f318b Mon Sep 17 00:00:00 2001 From: erdgeist Date: Mon, 6 Jan 2025 02:35:56 +0100 Subject: Make websocket address configurable --- fullnarp.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'fullnarp.py') diff --git a/fullnarp.py b/fullnarp.py index 71aa5f2..3a1262e 100644 --- a/fullnarp.py +++ b/fullnarp.py @@ -19,7 +19,7 @@ This is best served by an nginx block that should look a bit like this: } location /fullnarp/ws/ { - proxy_pass http://127.0.0.1:5009; + proxy_pass http://127.0.0.1:5042; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; @@ -206,7 +206,7 @@ async def main(): DATABASE_URL = config.get("database-uri", "sqlite:///test.db") - print("Connecting to " + DATABASE_URL) + print(f"Connecting to {DATABASE_URL}") engine = create_engine(DATABASE_URL, echo=False) SessionLocal = sessionmaker(bind=engine) Base.metadata.create_all(bind=engine) @@ -225,8 +225,11 @@ async def main(): current_version = {} newest_version = 0 - async with websockets.serve(handle_client, "localhost", 22378): - print("WebSocket server started on ws://localhost:22378") + ws_host = config.get("websocket-host", "localhost") + ws_port = config.get("websocket-port", 5042) + + async with websockets.serve(handle_client, ws_host, ws_port): + print(f"WebSocket server started on ws://{ws_host}:{ws_port}") await asyncio.Future() # Run forever -- cgit v1.2.3