From c80de43f55c89f82fcbfe058ca609011eec75c45 Mon Sep 17 00:00:00 2001 From: Keith Solomon Date: Mon, 20 Jul 2026 20:28:10 -0500 Subject: [PATCH] fix: run frontend without virtualenv - Modify app.py to add vendor/ to sys.path so pip --target works. - Add frontend/.gitignore to exclude vendor/, __pycache__, thermopro.db. - Update README with pip --target instructions. --- frontend/.gitignore | 6 ++++++ frontend/README.md | 47 +++++++++++++++++++++++++++++++-------------- frontend/app.py | 7 +++++++ 3 files changed, 46 insertions(+), 14 deletions(-) create mode 100644 frontend/.gitignore diff --git a/frontend/.gitignore b/frontend/.gitignore new file mode 100644 index 0000000..1b0bcb4 --- /dev/null +++ b/frontend/.gitignore @@ -0,0 +1,6 @@ +.venv +__pycache__/ +*.pyc +thermopro.db +vendor/ +.DS_Store diff --git a/frontend/README.md b/frontend/README.md index 5865d9e..88f85dc 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -6,7 +6,7 @@ A Progressive Web App (PWA) that consumes the CYD ThermoPro Bridge API, stores s ``` LXC/container -├── Python backend (FastAPI/Flask) +├── Python backend (Flask) │ ├── Polls CYD /api/latest periodically │ ├── Stores readings + sessions + notes in SQLite │ └── Serves the static PWA and API @@ -19,17 +19,37 @@ LXC/container ## Requirements -- Python 3.10+ -- `flask`, `requests`, `gunicorn` (or `uvicorn` if FastAPI) +- Python 3.10+ (system install or any working Python interpreter) - SQLite (stdlib) +Dependencies are installed locally into `frontend/vendor/` so no virtual environment is required. + +## Installing dependencies + +```bash +cd frontend +pip install --target vendor -r requirements.txt +``` + +On Windows with PowerShell: + +```powershell +cd "C:\Users\ksolo\Projects\House Projects\ThermoPro CYD\frontend" +pip install --target vendor -r requirements.txt +``` + ## Running locally ```bash cd frontend -python -m venv .venv -source .venv/bin/activate # Windows: .venv\Scripts\activate -pip install -r requirements.txt +CYD_BASE_URL=http://192.168.2.55 python app.py +``` + +On Windows with PowerShell: + +```powershell +cd "C:\Users\ksolo\Projects\House Projects\ThermoPro CYD\frontend" +$env:CYD_BASE_URL = "http://192.168.2.55" python app.py ``` @@ -37,14 +57,13 @@ Then open `http://localhost:5000`. ## Configuration -The backend needs to know the CYD IP. Set the environment variable: - -```bash -export CYD_BASE_URL=http://192.168.2.55 -``` - -or edit the default in `config.py`. +| Environment variable | Default | Description | +|----------------------|---------|-------------| +| `CYD_BASE_URL` | `http://192.168.2.55` | Base URL of the CYD bridge | +| `POLL_INTERVAL` | `5` | Seconds between backend polls | +| `DATABASE_PATH` | `thermopro.db` | SQLite database file | +| `DEFAULT_CHART_MINUTES` | `60` | Default chart time range | ## Deployment -Serve the app behind a reverse proxy (e.g. Caddy or Nginx) in an LXC. The backend will continue polling the CYD as long as it can reach the device. +Serve the app behind a reverse proxy (e.g. Caddy or Nginx) in an LXC. The backend continues polling the CYD as long as it can reach the device. diff --git a/frontend/app.py b/frontend/app.py index 73550e1..9a82fa5 100644 --- a/frontend/app.py +++ b/frontend/app.py @@ -1,7 +1,14 @@ import json +import sys import threading import time from datetime import datetime, timezone +from pathlib import Path + +# Add vendor/ to the import path so pip --target dependencies are found. +vendor_path = Path(__file__).parent / "vendor" +if vendor_path.exists(): + sys.path.insert(0, str(vendor_path)) import requests from flask import Flask, jsonify, request, render_template