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
|
||||
├── 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.
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user