File size: 1,287 Bytes
e2b424b
 
 
62b8e32
e2b424b
 
62b8e32
 
 
 
 
 
e2b424b
 
 
 
 
62b8e32
e2b424b
 
76f4dd7
e2b424b
62b8e32
e2b424b
62b8e32
e2b424b
 
 
 
 
 
62b8e32
981f742
e2b424b
 
76f4dd7
62b8e32
e2b424b
 
 
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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
@app.get("/")
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
@app.post("/readiness")
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
    }