static endpoints (font/img)

This commit is contained in:
grove5_admin committed 2026-04-28 12:15:42 -07:00
1 parent eaaefb9298
commit 6788dff984
3 files changed
+15 -3

No files matched your search

+9
View File
@@ -268,6 +268,15 @@ if UI_DIST.exists():
@app.get("/{full_path:path}") @app.get("/{full_path:path}")
async def serve_ui(full_path: str): async def serve_ui(full_path: str):
# Serve real files from dist/ (fonts, img, favicon, etc.) first
candidate = (UI_DIST / full_path).resolve()
try:
candidate.relative_to(UI_DIST.resolve()) # prevent path traversal
except ValueError:
raise HTTPException(status_code=404)
if full_path and candidate.is_file():
return FileResponse(candidate)
# Otherwise fall back to SPA index
index = UI_DIST / "index.html" index = UI_DIST / "index.html"
if index.exists(): if index.exists():
return FileResponse(index) return FileResponse(index)
+3 -3
View File
@@ -33,23 +33,23 @@ Startup sequence:
Configuration via environment variables (see Config below). Configuration via environment variables (see Config below).
""" """
from dotenv import load_dotenv
load_dotenv(override=True)
import asyncio import asyncio
import logging import logging
import os import os
import signal import signal
import sys import sys
import time
from pathlib import Path from pathlib import Path
import uvicorn import uvicorn
from cultivar_types import STM32Payload, Co2eCalibrationSample from cultivar_types import STM32Payload
from serial_reader import SerialManager from serial_reader import SerialManager
from processor import Processor, BaselineBuilder from processor import Processor, BaselineBuilder
from api import app, ws_manager from api import app, ws_manager
import storage import storage
# ── Logging ─────────────────────────────────────────────────────────────── # ── Logging ───────────────────────────────────────────────────────────────
logging.basicConfig( logging.basicConfig(
+3
View File
@@ -17,3 +17,6 @@ aiosqlite==0.22.1
# ── Serial I/O ──────────────────────────────────────────────────────────── # ── Serial I/O ────────────────────────────────────────────────────────────
pyserial-asyncio==0.6 pyserial-asyncio==0.6
# ── Environment variables ─────────────────────────────────────────────────
python-dotenv==1.1.0