2020-04-16 02:41:53 +03:00
|
|
|
#!/bin/bash
|
|
|
|
# Usage:
|
2020-05-16 01:47:39 +03:00
|
|
|
# ./run # Runs the full web app
|
|
|
|
# ./run test # Runs the testing suite
|
2020-04-16 02:41:53 +03:00
|
|
|
|
2020-05-16 01:36:01 +03:00
|
|
|
set -euo pipefail
|
2020-04-16 02:41:53 +03:00
|
|
|
|
2020-05-16 01:36:01 +03:00
|
|
|
SCRIPT_DIR="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
2020-04-16 02:41:53 +03:00
|
|
|
|
|
|
|
# Set directory to serve static content from
|
2020-05-16 01:36:01 +03:00
|
|
|
SUBDIR="${1:-app}"
|
|
|
|
export APP_ROOT="$SCRIPT_DIR/$SUBDIR"
|
|
|
|
export STATIC_FOLDER="$APP_ROOT/static"
|
2020-04-16 02:41:53 +03:00
|
|
|
|
|
|
|
# Check for regular vs test run
|
2020-05-16 01:36:01 +03:00
|
|
|
if [[ "$SUBDIR" == "test" ]]; then
|
2021-03-21 04:21:41 +03:00
|
|
|
# Set up static files for testing
|
|
|
|
rm -rf "$STATIC_FOLDER"
|
|
|
|
ln -s "$SCRIPT_DIR/app/static" "$STATIC_FOLDER"
|
2020-04-16 02:41:53 +03:00
|
|
|
pytest -sv
|
|
|
|
else
|
2021-03-21 04:21:41 +03:00
|
|
|
mkdir -p "$STATIC_FOLDER"
|
2020-05-16 01:36:01 +03:00
|
|
|
python3 -um app \
|
|
|
|
--host "${ADDRESS:-0.0.0.0}" \
|
2021-03-28 20:27:08 +03:00
|
|
|
--port "${PORT:-"${EXPOSE_PORT:-5000}"}" --debug
|
2020-04-16 02:41:53 +03:00
|
|
|
fi
|