From 5e3261d1f741ac52e77cc7e3238432d26dbe1d63 Mon Sep 17 00:00:00 2001 From: Maximilian Giller Date: Thu, 2 May 2024 17:53:49 +0200 Subject: [PATCH] Added latest endpoint --- src/endpoints/bettwaage.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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)