sensors is separate API with td

This commit is contained in:
2026-11-01 12:07:04 +01:00
parent b7048b401d
commit 85179c8a80
24 changed files with 1229 additions and 321 deletions
Executable
+48
View File
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
# Development launcher. Pick the service and port:
#
# ./run.sh # main app on 8000
# ./run.sh main 8000 # main app on 8000
# ./run.sh sensors 8001 # sensors app on 8001 (localhost only)
#
# The main app calls the sensors API server-to-server. Override its address
# when the sensors app is not on localhost:8001:
#
# SENSORS_API_URL=http://192.168.0.50:9001 ./run.sh main 8000
#
# The sensors API is open to every user on the local machine. To expose it
# on the network explicitly set HOST=0.0.0.0.
set -euo pipefail
cd "$(dirname "$0")"
APP="${1:-${APP:-main}}"
PORT="${2:-${PORT:-}}"
case "$APP" in
main)
MODULE="app:create_app"
DEFAULT_PORT=8000
DEFAULT_HOST="0.0.0.0"
;;
sensors)
MODULE="sensors_app:create_app"
DEFAULT_PORT=8001
DEFAULT_HOST="127.0.0.1"
;;
*)
echo "Usage: $0 [main|sensors] [port]" >&2
exit 2
;;
esac
PORT="${PORT:-$DEFAULT_PORT}"
HOST="${HOST:-$DEFAULT_HOST}"
if [ -x ".venv/bin/python" ]; then
PYTHON=".venv/bin/python"
else
PYTHON="python3"
fi
echo "Starting $APP app on http://$HOST:$PORT" >&2
exec "$PYTHON" -m flask --app "$MODULE" run --host "$HOST" --port "$PORT" --debug