From 7ec20ecf46f140b5bae1f598a541db8a9249e5ae Mon Sep 17 00:00:00 2001 From: Christopher Patton Date: Fri, 15 May 2020 15:36:01 -0700 Subject: [PATCH] Allow bind address override (#53) --- whoogle-search | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/whoogle-search b/whoogle-search index f87c61a..72f272d 100755 --- a/whoogle-search +++ b/whoogle-search @@ -3,23 +3,22 @@ # ./whoogle-search # Runs the full web app # ./whoogle-search test # Runs the testing suite -SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)" +set -euo pipefail -# Set default port if unavailable -if [[ -z "${PORT}" ]]; then - PORT="${EXPOSE_PORT:-5000}" -fi +SCRIPT_DIR="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" # Set directory to serve static content from -[[ ! -z $1 ]] && SUBDIR="$1" || SUBDIR="app" -export APP_ROOT=$SCRIPT_DIR/$SUBDIR -export STATIC_FOLDER=$APP_ROOT/static +SUBDIR="${1:-app}" +export APP_ROOT="$SCRIPT_DIR/$SUBDIR" +export STATIC_FOLDER="$APP_ROOT/static" -mkdir -p $STATIC_FOLDER +mkdir -p "$STATIC_FOLDER" # Check for regular vs test run -if [[ $SUBDIR == "test" ]]; then +if [[ "$SUBDIR" == "test" ]]; then pytest -sv else - python3 -um app --host 0.0.0.0 --port $PORT + python3 -um app \ + --host "${ADDRESS:-0.0.0.0}" \ + --port "${PORT:-"${EXPOSE_PORT:-5000}"}" fi