| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| from typing import Dict, List | |
| from app.model import RoommateMatcher | |
| app = FastAPI( | |
| title="Roommate Matcher API", | |
| openapi_url="/openapi.json", # π expose OpenAPI schema | |
| docs_url="/docs", # π enable Swagger docs | |
| redoc_url=None # optional | |
| ) | |
| matcher = RoommateMatcher() | |
| class MatchRequest(BaseModel): | |
| current_user: Dict | |
| other_users: List[Dict] | |
| def match(request: MatchRequest): | |
| try: | |
| result = matcher.predict(request.current_user, request.other_users) | |
| return {"matches": result} | |
| except Exception as e: | |
| return {"error": str(e)} | |