Files
stand/api.py
T
2026-05-12 12:04:15 +02:00

32 lines
621 B
Python

from datetime import datetime
from typing import Any
import pandas as pd
from fastapi import APIRouter
from singletons import PGroup, grids, lib
router = APIRouter()
@router.post("/tables/{pgroup}/append")
def append(pgroup: PGroup, row: dict[str, Any]):
now = datetime.now()
df = pd.DataFrame(row, index=[now])
lib.append(pgroup, df)
now = str(now) # nicegui converts datetime to str
row = {"index": now, **row} # setdefault would not force index to be the first column
res = []
for grid in grids[pgroup]:
grid.append(row)
res.append(grid.options)
return res