diff options
author | erdgeist <erdgeist@erdgeist.org> | 2025-01-06 02:35:56 +0100 |
---|---|---|
committer | erdgeist <erdgeist@erdgeist.org> | 2025-01-06 02:35:56 +0100 |
commit | 3696c9bfdb7a813419c8a53362260d59118f318b (patch) | |
tree | d9a4dc1c4f46026efdd6759656000e1779c9d10b /fullnarp.py | |
parent | cd949628c403d42a3cf58333a8b752f7b186fa81 (diff) |
Make websocket address configurable
Diffstat (limited to 'fullnarp.py')
-rw-r--r-- | fullnarp.py | 11 |
1 files changed, 7 insertions, 4 deletions
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: | |||
19 | } | 19 | } |
20 | 20 | ||
21 | location /fullnarp/ws/ { | 21 | location /fullnarp/ws/ { |
22 | proxy_pass http://127.0.0.1:5009; | 22 | proxy_pass http://127.0.0.1:5042; |
23 | proxy_http_version 1.1; | 23 | proxy_http_version 1.1; |
24 | proxy_set_header Upgrade $http_upgrade; | 24 | proxy_set_header Upgrade $http_upgrade; |
25 | proxy_set_header Connection 'upgrade'; | 25 | proxy_set_header Connection 'upgrade'; |
@@ -206,7 +206,7 @@ async def main(): | |||
206 | 206 | ||
207 | DATABASE_URL = config.get("database-uri", "sqlite:///test.db") | 207 | DATABASE_URL = config.get("database-uri", "sqlite:///test.db") |
208 | 208 | ||
209 | print("Connecting to " + DATABASE_URL) | 209 | print(f"Connecting to {DATABASE_URL}") |
210 | engine = create_engine(DATABASE_URL, echo=False) | 210 | engine = create_engine(DATABASE_URL, echo=False) |
211 | SessionLocal = sessionmaker(bind=engine) | 211 | SessionLocal = sessionmaker(bind=engine) |
212 | Base.metadata.create_all(bind=engine) | 212 | Base.metadata.create_all(bind=engine) |
@@ -225,8 +225,11 @@ async def main(): | |||
225 | current_version = {} | 225 | current_version = {} |
226 | newest_version = 0 | 226 | newest_version = 0 |
227 | 227 | ||
228 | async with websockets.serve(handle_client, "localhost", 22378): | 228 | ws_host = config.get("websocket-host", "localhost") |
229 | print("WebSocket server started on ws://localhost:22378") | 229 | ws_port = config.get("websocket-port", 5042) |
230 | |||
231 | async with websockets.serve(handle_client, ws_host, ws_port): | ||
232 | print(f"WebSocket server started on ws://{ws_host}:{ws_port}") | ||
230 | await asyncio.Future() # Run forever | 233 | await asyncio.Future() # Run forever |
231 | 234 | ||
232 | 235 | ||