diff --git a/src/main.py b/src/main.py index a65f696..c904985 100644 --- a/src/main.py +++ b/src/main.py @@ -20,7 +20,11 @@ def main(): if cli.showGUI(): raise Exception('Not yet implemented') elif cli.startFlaskServer(): - solo_turnier.flask.startFlask(batchWorker, cli.getLogLevel() > 0) + solo_turnier.flask.startFlask( + batchWorker, + debug=cli.getLogLevel() > 0, + port=cli.getPort() + ) else: combinedData = batchWorker.run() diff --git a/src/solo_turnier/cli.py b/src/solo_turnier/cli.py index 1708cbb..d1038c6 100644 --- a/src/solo_turnier/cli.py +++ b/src/solo_turnier/cli.py @@ -8,6 +8,7 @@ class Cli: parser = argparse.ArgumentParser() # parser.add_argument('--gui', help='Show the GUI', action='store_true') parser.add_argument('--no-flask', action='store_false', dest='flask', help='Disable the internal flask web server') + parser.add_argument('--port', help='The port to listen for incoming requests') parser.add_argument('html', help='The path from where to look for HTML export files', nargs=1, default=['.']) parser.add_argument('-o', '--output', help='Set the output path of the script', nargs=1, default=[None]) @@ -52,3 +53,6 @@ class Cli: def showAllParticipants(self): return self.__args.all_participants + + def getPort(self): + return int(self.__args.port) diff --git a/src/solo_turnier/flask.py b/src/solo_turnier/flask.py index 5f6d0df..07cd199 100644 --- a/src/solo_turnier/flask.py +++ b/src/solo_turnier/flask.py @@ -1,7 +1,11 @@ import flask import solo_turnier -def startFlask(batchWorker: solo_turnier.batch.BatchWorker, debug: bool = False): +def startFlask( + batchWorker: solo_turnier.batch.BatchWorker, + debug: bool = False, + port: int = 8082 + ): app = flask.Flask(__name__) @app.route('/') @@ -10,4 +14,4 @@ def startFlask(batchWorker: solo_turnier.batch.BatchWorker, debug: bool = False) return flask.render_template('index.html', data=combinedData) - app.run(host='0.0.0.0', port=8082, debug=debug) + app.run(host='0.0.0.0', port=port, debug=debug)