Files
test-search-engine/app/main.py
T

31 lines
854 B
Python

from __future__ import annotations
import os
from pathlib import Path
from fastapi import FastAPI
from app.catalog import load_raw_catalog
from app.models import MatchRequest, MatchResponse, MatchResult
BASE_DIR = Path(__file__).resolve().parent.parent
CATALOG_PATH = Path(os.environ.get("CATALOG_PATH", BASE_DIR / "catalog_excel.csv"))
RAW_CATALOG = load_raw_catalog(CATALOG_PATH)
app = FastAPI(title="Offline catalog matcher", version="0.1.0")
@app.get("/health")
def health() -> dict[str, object]:
return {"status": "ok", "catalog_items": len(RAW_CATALOG)}
@app.post("/match", response_model=MatchResponse)
def match(request: MatchRequest) -> MatchResponse:
return MatchResponse(
results=[
MatchResult(message=message, status="not_found", candidates=[])
for message in request.messages
]
)