Spaces:
Sleeping
Sleeping
Add FastAPI backend and integrate with Gradio frontend for workout plan generation
Browse files- backend.py +18 -0
backend.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
+
|
| 4 |
+
app = FastAPI()
|
| 5 |
+
|
| 6 |
+
class UserData(BaseModel):
|
| 7 |
+
weight: float
|
| 8 |
+
height: float
|
| 9 |
+
age: int
|
| 10 |
+
body_type: str
|
| 11 |
+
goals: str
|
| 12 |
+
preferences: str
|
| 13 |
+
|
| 14 |
+
@app.post("/generate_plan")
|
| 15 |
+
def generate_plan(data: UserData):
|
| 16 |
+
# L贸gica para gerar o plano de treino personalizado
|
| 17 |
+
plan = f"Generated plan for {data.body_type} body type with goals: {data.goals} and preferences: {data.preferences}"
|
| 18 |
+
return {"plan": plan}
|