From 3c31c41acd08f6f28e4bc019f7bdd7e3ec063d7f Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sun, 2 May 2021 01:47:40 +0000 Subject: [PATCH] Try different ports for web interface --- main.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 258beea..2453329 100644 --- a/main.py +++ b/main.py @@ -91,14 +91,22 @@ def main(): observer.stop() observer.join() - -if __name__ == '__main__': +def run_api(): host = '0.0.0.0' port = 3300 - threading.Thread(target=app.run, kwargs={'host': host, 'port': port}).start() - print('Web interface listening on port:', port) - print('Try going to http://localhost:' + str(port)) + while True: + print('Trying to run web interface on port:', port) + print('If it works, go to http://localhost:' + str(port)) + try: + app.run(host=host, port=port) + except OSError: + print() + print('Error: Port already taken.') + port += 1 + +if __name__ == '__main__': + threading.Thread(target=run_api).start() time.sleep(1) main()