Make rascsi-web port configurable (#471)

This commit is contained in:
Daniel Markstedt 2021-11-15 11:00:32 -08:00 committed by GitHub
parent 0f222df9a2
commit 111920edb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 3 deletions

View File

@ -55,5 +55,21 @@ else
fi fi
fi fi
echo "Starting web server..." # parse arguments
python3 web.py 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}

View File

@ -3,6 +3,7 @@ Module for the Flask app rendering and endpoints
""" """
import logging import logging
from sys import argv
from pathlib import Path from pathlib import Path
from flask import ( from flask import (
@ -820,6 +821,11 @@ if __name__ == "__main__":
if Path(f"{CFG_DIR}/{DEFAULT_CONFIG}").is_file(): if Path(f"{CFG_DIR}/{DEFAULT_CONFIG}").is_file():
read_config(DEFAULT_CONFIG) read_config(DEFAULT_CONFIG)
if len(argv) > 1:
port = int(argv[1])
else:
port = 8080
import bjoern import bjoern
print("Serving rascsi-web...") print("Serving rascsi-web...")
bjoern.run(APP, "0.0.0.0", 8080) bjoern.run(APP, "0.0.0.0", port)