summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2020-05-14 21:51:14 +0200
committerOlivier Gayot <olivier.gayot@sigexec.com>2020-05-15 02:47:20 +0200
commit638af2c54513a928e6fe82bcb2932c09da6931b2 (patch)
treeb157d2dffdffe4893b9dbefe2c9bd08972f2da6e
parent2f952abf82c36c817cbbc1e3654b990a496d50ad (diff)
Take the listen address and port as optional arguments
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
-rw-r--r--swiftstory/SwiftStory.py8
1 files changed, 7 insertions, 1 deletions
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()