feat: add webapp
This commit is contained in:
+8
-1
@@ -36,13 +36,14 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
# FastAPI / Pydantic
|
||||
try:
|
||||
from fastapi import Body, FastAPI, HTTPException, Query
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.responses import FileResponse, JSONResponse
|
||||
from pydantic import BaseModel
|
||||
import uvicorn
|
||||
except ImportError:
|
||||
@@ -246,6 +247,12 @@ def health() -> dict:
|
||||
return {"status": "ok", "service": "sfm", "version": "0.1.0"}
|
||||
|
||||
|
||||
@app.get("/", response_class=FileResponse)
|
||||
def webapp():
|
||||
"""Serve the SFM web app."""
|
||||
return str(Path(__file__).parent / "sfm_webapp.html")
|
||||
|
||||
|
||||
@app.get("/device/info")
|
||||
def device_info(
|
||||
port: Optional[str] = Query(None, description="Serial port (e.g. COM5, /dev/ttyUSB0)"),
|
||||
|
||||
+1110
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user