diff --git a/src/endpoints/bettwaage.py b/src/endpoints/bettwaage.py index 2efad60..0c8e577 100644 --- a/src/endpoints/bettwaage.py +++ b/src/endpoints/bettwaage.py @@ -3,7 +3,7 @@ from fastapi import APIRouter from datetime import datetime import os -from fastapi.responses import HTMLResponse +from fastapi.responses import HTMLResponse, JSONResponse router = APIRouter() @@ -43,6 +43,20 @@ async def add_weight(tl: int, tr: int, bl: int, br: int): add_line_to_history(f"{str(datetime.now())};{tl};{tr};{bl};{br};{sum};") +@router.post("/latest") +async def get_latest(): + total = sum(latest_values) + return JSONResponse( + { + "top-left": latest_values[0], + "top-right": latest_values[1], + "bottom-left": latest_values[2], + "bottom-right": latest_values[3], + "total": total, + } + ) + + @router.post("/delete", tags=["file"]) async def delete_file(): os.remove(file_path)