Files
yunke/yunke-server/app/api/main.py
T

40 lines
1003 B
Python
Raw Normal View History

2026-08-01 12:10:03 +08:00
"""FastAPI app for the yunke data-mirror viewing API.
Run locally with::
uvicorn app.api.main:app --reload
Includes:
* ``GET /api/health`` -> ``{"status": "ok"}`` liveness probe.
* ``GET /api/customers`` (see :mod:`app.api.routers.customer`).
2026-08-01 14:13:50 +08:00
* ``GET /api/media/{media_hash}`` (see :mod:`app.api.routers.media`).
2026-08-01 12:10:03 +08:00
CORS is configured permissively (wildcard origin, no credentials) so the local
frontend can call the API during development. Auth / finer CORS are LATER tasks.
"""
from __future__ import annotations
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
2026-08-01 14:13:50 +08:00
from app.api.routers import customer, media
2026-08-01 12:10:03 +08:00
app = FastAPI(title="yunke data mirror")
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(customer.router)
2026-08-01 14:13:50 +08:00
app.include_router(media.router)
2026-08-01 12:10:03 +08:00
@app.get("/api/health")
async def health() -> dict[str, str]:
"""Trivial liveness probe."""
return {"status": "ok"}