From 254177e630e2eea26835522e35fd8035ac553825 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 29 Apr 2024 15:16:44 +1200 Subject: [PATCH] support setting host and port via cli args --- README.md | 2 +- web.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 277e521..0e3af17 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ python web.py ## TODO -- [ ] allow passing in a custom port to serve on via cli args +- [ ] don't start Reticulum before cli args have been parsed - [ ] allow passing in a custom Reticulum config file via cli args - [ ] conversations/contacts list ui with unread indicators - [ ] create/import/export identities in the web ui diff --git a/web.py b/web.py index 6ddb35d..5bbe3a8 100644 --- a/web.py +++ b/web.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import argparse import json import RNS @@ -32,8 +33,17 @@ websocket_clients = [] async def main(): + # parse command line args + parser = argparse.ArgumentParser(description="ReticulumWebChat") + parser.add_argument("--host", nargs='?', default="0.0.0.0", type=str) + parser.add_argument("--port", nargs='?', default="8000", type=int) + args = parser.parse_args() + # run sanic app - app.run() + app.run( + host=args.host, + port=args.port, + ) # set a callback for when an lxmf message is received message_router.register_delivery_callback(lxmf_delivery)