80b3d23b75
Use the models router for curves and training inputs, the EEG router for summary, and a separate preview router. Keep the preview result typed with the existing persistence model and declare multipart binary schemas for generated Blob parameters.
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
from fastapi import Depends, FastAPI, Request
|
|
from fastapi.exception_handlers import http_exception_handler
|
|
from starlette.exceptions import HTTPException
|
|
|
|
from core.domains import Domain
|
|
from webapi import eeg, execution, fhir, ingest, models, preview, review, runs
|
|
from webapi.auth import caller
|
|
|
|
app = FastAPI(
|
|
title="ISSSTELEON",
|
|
version="0.0.0",
|
|
dependencies=[Depends(caller)], # every route; where authentication will go
|
|
generate_unique_id_function=lambda route: route.name, # clean names in the generated client
|
|
)
|
|
app.include_router(ingest.router)
|
|
app.include_router(review.router)
|
|
app.include_router(runs.router)
|
|
app.include_router(execution.router)
|
|
app.include_router(models.router)
|
|
app.include_router(eeg.router)
|
|
app.include_router(preview.router)
|
|
app.include_router(fhir.router)
|
|
|
|
|
|
@app.exception_handler(HTTPException)
|
|
async def errors(request: Request, error: HTTPException):
|
|
"""FHIR routes answer errors as an OperationOutcome."""
|
|
if "/fhir/" in request.url.path or request.url.path.endswith("/fhir"):
|
|
return fhir.outcome(error.status_code, str(error.detail))
|
|
return await http_exception_handler(request, error)
|
|
|
|
|
|
@app.get("/health")
|
|
def health() -> dict[str, str]:
|
|
return {"status": "ok"}
|
|
|
|
|
|
@app.get("/domains")
|
|
def domains() -> list[Domain]:
|
|
return list(Domain)
|