# Installation ## Requirements - Python 3.11+ - pip - SQLite (included) or PostgreSQL ## Development Setup ```bash # Clone repository cd ~/git/esp32-web # Create virtual environment python3 -m venv .venv source .venv/bin/activate # Install with dev dependencies pip install -e ".[dev]" # Initialize database flask --app src/esp32_web db init flask --app src/esp32_web db migrate -m "initial" flask --app src/esp32_web db upgrade # Verify installation make test ``` ## Configuration Copy `.env.example` to `.env` and adjust: ```bash cp .env.example .env ``` | Variable | Default | Description | |----------|---------|-------------| | SECRET_KEY | dev-key | Flask secret key | | DATABASE_URL | sqlite:///esp32.db | Database connection | | UDP_PORT | 5500 | UDP collector port | | CMD_PORT | 5501 | Sensor command port | | SENSOR_TIMEOUT | 60 | Seconds before sensor marked offline | ## Container Deployment ```bash # Build image make build # Run container make container-run # View logs make container-logs # Stop container make container-stop ``` ## Production For production, use gunicorn: ```bash gunicorn -b 0.0.0.0:5500 -w 4 'esp32_web:create_app()' ``` With PostgreSQL: ```bash export DATABASE_URL="postgresql://user:pass@localhost/esp32web" flask --app src/esp32_web db upgrade ```