static endpoints (font/img)
This commit is contained in:
1 parent
eaaefb9298
commit
6788dff984
3 files changed
+15
-3
No files matched your search
@@ -268,6 +268,15 @@ if UI_DIST.exists():
|
||||
|
||||
@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
@@ -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(
|
||||
|
||||
@@ -17,3 +17,6 @@ aiosqlite==0.22.1
|
||||
|
||||
# ── Serial I/O ────────────────────────────────────────────────────────────
|
||||
pyserial-asyncio==0.6
|
||||
|
||||
# ── Environment variables ─────────────────────────────────────────────────
|
||||
python-dotenv==1.1.0
|
||||
Reference in new issue
Block a user