On app init, short hashes are generated from file checksums to use for cache busting. These hashes are added into the full file name and used to symlink to the actual file contents. These symlinks are loaded in the jinja templates for each page, and can tell the browser to load a new file if the hash changes. This is only in place for css and js files, but can be extended in the future for other file types if needed.
29 lines
698 B
Bash
Executable File
29 lines
698 B
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)"
|
|
|
|
# Set directory to serve static content from
|
|
SUBDIR="${1:-app}"
|
|
export APP_ROOT="$SCRIPT_DIR/$SUBDIR"
|
|
export STATIC_FOLDER="$APP_ROOT/static"
|
|
|
|
rm -rf $STATIC_FOLDER/build
|
|
|
|
# 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"
|
|
python3 -um app \
|
|
--host "${ADDRESS:-0.0.0.0}" \
|
|
--port "${PORT:-"${EXPOSE_PORT:-5000}"}"
|
|
fi
|