From 638af2c54513a928e6fe82bcb2932c09da6931b2 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Thu, 14 May 2020 21:51:14 +0200 Subject: Take the listen address and port as optional arguments Signed-off-by: Olivier Gayot --- swiftstory/SwiftStory.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'swiftstory') diff --git a/swiftstory/SwiftStory.py b/swiftstory/SwiftStory.py index 196c3dc..e77363d 100644 --- a/swiftstory/SwiftStory.py +++ b/swiftstory/SwiftStory.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import argparse import asyncio import websockets @@ -68,7 +69,12 @@ async def swiftstory(websocket, path): def main(): - start_server = websockets.serve(swiftstory, '0.0.0.0', 1236) + parser = argparse.ArgumentParser() + parser.add_argument('--listen', type=str, default='0.0.0.0') + parser.add_argument('--port', type=int, default=1236) + args = vars(parser.parse_args()) + + start_server = websockets.serve(swiftstory, args['listen'], args['port']) asyncio.get_event_loop().run_until_complete(start_server) asyncio.get_event_loop().run_forever() -- cgit v1.2.3