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
+17 -5

No files matched your search

+10 -1
View File
@@ -265,9 +265,18 @@ async def reset_baseline(
if UI_DIST.exists():
app.mount("/assets", StaticFiles(directory=UI_DIST / "assets"), name="assets")
@app.get("/{full_path:path}")
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"
if index.exists():
return FileResponse(index)
+3 -3
View File
@@ -33,23 +33,23 @@ Startup sequence:
Configuration via environment variables (see Config below).
"""
from dotenv import load_dotenv
load_dotenv(override=True)
import asyncio
import logging
import os
import signal
import sys
import time
from pathlib import Path
import uvicorn
from cultivar_types import STM32Payload, Co2eCalibrationSample
from cultivar_types import STM32Payload
from serial_reader import SerialManager
from processor import Processor, BaselineBuilder
from api import app, ws_manager
import storage
# ── Logging ───────────────────────────────────────────────────────────────
logging.basicConfig(
+4 -1
View File
@@ -16,4 +16,7 @@ pydantic==2.13.3
aiosqlite==0.22.1
# ── Serial I/O ────────────────────────────────────────────────────────────
pyserial-asyncio==0.6
pyserial-asyncio==0.6
# ── Environment variables ─────────────────────────────────────────────────
python-dotenv==1.1.0