prerelease of list from serrver-db
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user