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.
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
.venv
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
thermopro.db
|
||||||
|
vendor/
|
||||||
|
.DS_Store
|
||||||
+33
-14
@@ -6,7 +6,7 @@ A Progressive Web App (PWA) that consumes the CYD ThermoPro Bridge API, stores s
|
|||||||
|
|
||||||
```
|
```
|
||||||
LXC/container
|
LXC/container
|
||||||
├── Python backend (FastAPI/Flask)
|
├── Python backend (Flask)
|
||||||
│ ├── Polls CYD /api/latest periodically
|
│ ├── Polls CYD /api/latest periodically
|
||||||
│ ├── Stores readings + sessions + notes in SQLite
|
│ ├── Stores readings + sessions + notes in SQLite
|
||||||
│ └── Serves the static PWA and API
|
│ └── Serves the static PWA and API
|
||||||
@@ -19,17 +19,37 @@ LXC/container
|
|||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- Python 3.10+
|
- Python 3.10+ (system install or any working Python interpreter)
|
||||||
- `flask`, `requests`, `gunicorn` (or `uvicorn` if FastAPI)
|
|
||||||
- SQLite (stdlib)
|
- 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
|
## Running locally
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd frontend
|
cd frontend
|
||||||
python -m venv .venv
|
CYD_BASE_URL=http://192.168.2.55 python app.py
|
||||||
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
```
|
||||||
pip install -r requirements.txt
|
|
||||||
|
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
|
python app.py
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -37,14 +57,13 @@ Then open `http://localhost:5000`.
|
|||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
The backend needs to know the CYD IP. Set the environment variable:
|
| Environment variable | Default | Description |
|
||||||
|
|----------------------|---------|-------------|
|
||||||
```bash
|
| `CYD_BASE_URL` | `http://192.168.2.55` | Base URL of the CYD bridge |
|
||||||
export CYD_BASE_URL=http://192.168.2.55
|
| `POLL_INTERVAL` | `5` | Seconds between backend polls |
|
||||||
```
|
| `DATABASE_PATH` | `thermopro.db` | SQLite database file |
|
||||||
|
| `DEFAULT_CHART_MINUTES` | `60` | Default chart time range |
|
||||||
or edit the default in `config.py`.
|
|
||||||
|
|
||||||
## Deployment
|
## 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.
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
import json
|
import json
|
||||||
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
from datetime import datetime, timezone
|
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
|
import requests
|
||||||
from flask import Flask, jsonify, request, render_template
|
from flask import Flask, jsonify, request, render_template
|
||||||
|
|||||||
Reference in New Issue
Block a user