From b3c9ae922cc659e9760ba2f2e1b9166c89ca280a Mon Sep 17 00:00:00 2001 From: Justin Donofrio Date: Sun, 22 Dec 2024 15:38:26 -0500 Subject: [PATCH] Add host and port options to the web ui --- src/onthespot/web.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/onthespot/web.py b/src/onthespot/web.py index 701a712..97a6281 100644 --- a/src/onthespot/web.py +++ b/src/onthespot/web.py @@ -1,6 +1,7 @@ import os # Required for librespot-python os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python' +import argparse import json import threading import time @@ -186,7 +187,7 @@ def update_settings(): return jsonify(success=True) -def main(): +def main(host, port, debug): fill_account_pool = FillAccountPool() fill_account_pool.finished.connect(lambda: logger.info("Finished filling account pool.")) @@ -212,8 +213,14 @@ def main(): mirrorplayback = MirrorSpotifyPlayback() mirrorplayback.start() - app.run(debug=True) + app.run(host=host, port=port, debug=debug) if __name__ == '__main__': - main() + parser = argparse.ArgumentParser() + parser.add_argument('--host', type=str, default='127.0.0.1', help='Host IP address') + parser.add_argument('--port', type=int, default=5000, help='Port number') + parser.add_argument('--debug', action='store_true', help='Enable debug mode') + args = parser.parse_args() + + main(args.host, args.port, args.debug)