Added latest endpoint
This commit is contained in:
parent
7b21fa130f
commit
5e3261d1f7
1 changed files with 15 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue