44 lines
1.1 KiB
Bash
Executable File
44 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Usage:
|
|
# ./run # Runs the full web app
|
|
# ./run test # Runs the testing suite
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
|
|
|
if [[ ! -x "$(command -v python3)" ]]; then
|
|
echo "Python3 required -- please install first"
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -d "$SCRIPT_DIR/venv" ]]; then
|
|
python3 -m venv venv
|
|
"$SCRIPT_DIR"/venv/bin/pip install --upgrade pip
|
|
"$SCRIPT_DIR"/venv/bin/pip install -r requirements.txt
|
|
fi
|
|
|
|
cd "$SCRIPT_DIR"
|
|
|
|
# Set directory to serve static content from
|
|
SUBDIR="${1:-app}"
|
|
export APP_ROOT="$SCRIPT_DIR/$SUBDIR"
|
|
export STATIC_FOLDER="$APP_ROOT/static"
|
|
|
|
# Clear out build directory
|
|
rm -f "$SCRIPT_DIR"/app/static/build/*.js
|
|
rm -f "$SCRIPT_DIR"/app/static/build/*.css
|
|
|
|
# Check for regular vs test run
|
|
if [[ "$SUBDIR" == "test" ]]; then
|
|
# Set up static files for testing
|
|
rm -rf "$STATIC_FOLDER"
|
|
ln -s "$SCRIPT_DIR/app/static" "$STATIC_FOLDER"
|
|
pytest -sv
|
|
else
|
|
mkdir -p "$STATIC_FOLDER"
|
|
"$SCRIPT_DIR"/venv/bin/python -um app \
|
|
--host "${ADDRESS:-0.0.0.0}" \
|
|
--port "${PORT:-"${EXPOSE_PORT:-5000}"}"
|
|
fi
|