prerelease of list from serrver-db

This commit is contained in:
2026-01-12 15:03:47 +01:00
parent c4b5cac768
commit 7a8b3928a6
10 changed files with 270 additions and 48 deletions
+21 -3
View File
@@ -1,9 +1,7 @@
from justgetit.constants import *
import httpx
import json
import toga
class BackEnd():
"""
This is the interface for the backend.
@@ -32,7 +30,6 @@ class BackEnd():
response = await client.post(f"{API}/{endpoint}", data=parameters)
self.payload = response.json()
self.status = int(self.payload['status'])
print(f" payload {self.payload}")
except httpx.RequestError as exc:
self.status = -2
@@ -50,3 +47,24 @@ class BackEnd():
callback(parameters, self.payload)
def postwait(self, endpoint, parameters):
"""
Call the server, always with a POST, for a specific endpoint and the parameters
in the body
:param endpoint: the endpoint without /api/ (no slashes)
:param parameters: A dict with the parameters for the call
:param callback: def in the calling function to return to
"""
self.status = 0
self.payload = None
if len(endpoint)>2:
try:
response = httpx.post(f"{API}/{endpoint}", data=parameters)
self.payload = response.json()
self.status = int(self.payload['status'])
except httpx.RequestError as exc:
self.status = -2
return self.payload