static endpoints (font/img)
This commit is contained in:
1 parent
eaaefb9298
commit
6788dff984
3 files changed
+17
-5
No files matched your search
@@ -265,9 +265,18 @@ async def reset_baseline(
|
|||||||
|
|
||||||
if UI_DIST.exists():
|
if UI_DIST.exists():
|
||||||
app.mount("/assets", StaticFiles(directory=UI_DIST / "assets"), name="assets")
|
app.mount("/assets", StaticFiles(directory=UI_DIST / "assets"), name="assets")
|
||||||
|
|
||||||
@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
@@ -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(
|
||||||
|
|||||||
+4
-1
@@ -16,4 +16,7 @@ pydantic==2.13.3
|
|||||||
aiosqlite==0.22.1
|
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
|
||||||
Reference in new issue
Block a user