Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| # Create the FastAPI app | |
| app = FastAPI() | |
| # Add a simple root path so you don't get a "Not Found" error on browser visit | |
| def root(): | |
| return {"message": "Welcome to the Project Readiness API. Use POST /readiness to submit data."} | |
| # Define the input payload model | |
| class InputPayload(BaseModel): | |
| project_id: str | |
| open_punch_items: int | |
| missing_docs: int | |
| # Define the /readiness API endpoint | |
| async def readiness_check(payload: InputPayload): | |
| # Calculate readiness score | |
| penalties = payload.open_punch_items + payload.missing_docs | |
| readiness_score = max(0, 100 - penalties * 10) | |
| # Identify what's missing | |
| missing_items = [] | |
| if payload.open_punch_items > 0: | |
| missing_items.append("Punch List Incomplete") | |
| if payload.missing_docs > 0: | |
| missing_items.append("Documents Missing") | |
| # Simulated PDF link (replace with real logic later) | |
| pdf_url = f"https://huggingface.co/spaces/Dineshpopuri/project-readiness-api/blob/main/{payload.project_id}_closure_pack.pdf" | |
| return { | |
| "project_id": payload.project_id, | |
| "readiness_score": readiness_score, | |
| "missing_items": missing_items, | |
| "pdf_url": pdf_url | |
| } |