File size: 703 Bytes
7958e55
 
 
 
 
362059e
 
 
 
 
 
 
7958e55
 
 
 
 
 
 
 
 
 
 
 
0b6fe9c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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]

@app.post("/match")
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)}