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

29 lines
829 B
Python

from __future__ import annotations
import os
from pathlib import Path
from fastapi import FastAPI
from app.matcher import CatalogMatcher
from app.models import MatchRequest, MatchResponse
BASE_DIR = Path(__file__).resolve().parent.parent
CATALOG_PATH = Path(os.environ.get("CATALOG_PATH", BASE_DIR / "catalog_excel.csv"))
MATCHER = CatalogMatcher(CATALOG_PATH)
# The task asks for one application endpoint. OpenAPI/Swagger routes are disabled
# so the running service exposes only POST /match.
app = FastAPI(
title="Offline catalog matcher",
version="0.2.0",
docs_url=None,
redoc_url=None,
openapi_url=None,
)
@app.post("/match", response_model=MatchResponse)
def match(request: MatchRequest) -> MatchResponse:
return MatchResponse(results=[MATCHER.match(message) for message in request.messages])