From 111920edb0fbbfe3b675397e2bee80aedef0cc2b Mon Sep 17 00:00:00 2001 From: Daniel Markstedt Date: Mon, 15 Nov 2021 11:00:32 -0800 Subject: [PATCH] Make rascsi-web port configurable (#471) --- src/web/start.sh | 20 ++++++++++++++++++-- src/web/web.py | 8 +++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/web/start.sh b/src/web/start.sh index cfae1656..cd4b18d6 100755 --- a/src/web/start.sh +++ b/src/web/start.sh @@ -55,5 +55,21 @@ else fi fi -echo "Starting web server..." -python3 web.py +# parse arguments +while [ "$1" != "" ]; do + PARAM=$(echo "$1" | awk -F= '{print $1}') + VALUE=$(echo "$1" | awk -F= '{print $2}') + case $PARAM in + -p | --port) + PORT=$VALUE + ;; + *) + echo "ERROR: unknown parameter \"$PARAM\"" + exit 1 + ;; + esac + shift +done + +echo "Starting web server on port ${PORT-8080}..." +python3 web.py ${PORT} diff --git a/src/web/web.py b/src/web/web.py index 492fa37b..8ac26e28 100644 --- a/src/web/web.py +++ b/src/web/web.py @@ -3,6 +3,7 @@ Module for the Flask app rendering and endpoints """ import logging +from sys import argv from pathlib import Path from flask import ( @@ -820,6 +821,11 @@ if __name__ == "__main__": if Path(f"{CFG_DIR}/{DEFAULT_CONFIG}").is_file(): read_config(DEFAULT_CONFIG) + if len(argv) > 1: + port = int(argv[1]) + else: + port = 8080 + import bjoern print("Serving rascsi-web...") - bjoern.run(APP, "0.0.0.0", 8080) + bjoern.run(APP, "0.0.0.0", port)