forked from i4c0ni99/FoodAI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequestFE.py
More file actions
38 lines (31 loc) · 1012 Bytes
/
requestFE.py
File metadata and controls
38 lines (31 loc) · 1012 Bytes
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
from fastapi import FastAPI
from pydantic import BaseModel
from fastapi.middleware.cors import CORSMiddleware
from trainingML import trainerPranzo
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Permetti tutte le origini, puoi specificare una lista di domini
allow_credentials=True,
allow_methods=["*"], # Permetti tutti i metodi HTTP (GET, POST, etc.)
allow_headers=["*"], # Permetti tutte le intestazioni
)
class ReqeustFE(BaseModel):
tdee: float
carb_g: float
protein_g: float
fat_g: float
cena:float
colazione:float
pranzo:float
spuntino_mat:float
spuntino_pom:float
aliments:list
@app.post("/goals/")
async def create_item(requestFE: ReqeustFE):
if requestFE.pranzo:
return trainerPranzo(requestFE.pranzo,requestFE.aliments)
return "non ci sono risposte dal server"
if __name__ == '__main__':
import uvicorn
uvicorn.run(app, host="127.0.0.1", port=8000)