Maybe fixed write endpoint?
This commit is contained in:
parent
ed1f6a7475
commit
eac465e1a8
1 changed files with 4 additions and 3 deletions
|
@ -9,6 +9,7 @@ import csv
|
|||
router = APIRouter()
|
||||
|
||||
file_path = "bettwaage.csv"
|
||||
header = "timestamp;tl;tr;bl;br;total;"
|
||||
|
||||
latest_values = []
|
||||
zero_values = [0, 0, 0, 0]
|
||||
|
@ -16,7 +17,7 @@ scale_values = [1, 1, 1, 1]
|
|||
|
||||
|
||||
def add_line_to_history(line: str) -> None:
|
||||
with open(file_path, "a", encoding="UTF-8") as fp:
|
||||
with open(file_path, "a") as fp:
|
||||
fp.write(line + "\n")
|
||||
|
||||
|
||||
|
@ -90,7 +91,7 @@ async def get_latest():
|
|||
@router.delete("/delete", tags=["file"])
|
||||
async def delete_file():
|
||||
os.remove(file_path)
|
||||
add_line_to_history("timestamp;tl;tr;bl;br;total;")
|
||||
add_line_to_history(header)
|
||||
return "Deleted file and created new file with headers"
|
||||
|
||||
|
||||
|
@ -113,4 +114,4 @@ async def set_scales(tl: float, tr: float, bl: float, br: float):
|
|||
|
||||
|
||||
if not os.path.exists(file_path):
|
||||
add_line_to_history("timestamp;tl;tr;bl;br;total;")
|
||||
add_line_to_history(header)
|
||||
|
|
Loading…
Reference in a new issue