from fastapi import FastAPI
from fastapi.responses import JSONResponse
from dotenv import load_dotenv
import os
from utils import wellnessScore, uvfScore
from response import response

load_dotenv()
HOST = os.getenv("HOST", "0.0.0.0")
PORT = int(os.getenv("PORT", 8000))

app = FastAPI()

@app.get("/")
def base():
    return {"Welltra-Report"}

@app.get("/health")
def health_check():
    try:
        return {"status": "healthy"}
    except Exception as e:
        return {"status": "unhealthy", "error": str(e)}

@app.post("/w_score", response_class=JSONResponse)
def wellness_score(data: wellnessScore):
    """
    Expects JSON body like:
    {
        "heart_rate": 72,
        "sleep": 7,
        ...
    }
    """
    return response(data,True)

@app.post("/uvf_score", response_class=JSONResponse)
def urine_vital_functional_score(data: uvfScore):
    """
    Expects JSON body matching uvfScore model.
    """
    return response(data)

if __name__ == "__main__":
    import uvicorn
    uvicorn.run("main:app", host=HOST, port=PORT)
