lkjlkjdsalkj

This commit is contained in:
Peder Bergebakken Sundt 2024-05-10 20:04:30 +02:00
parent f3cbb43f91
commit 7e8baa0a48
2 changed files with 4 additions and 1 deletions

View File

@ -24,7 +24,7 @@ A set of simple API endpoints and ready-to-go clients to interface with the [Grz
As the user intended to run the server: As the user intended to run the server:
pip install --user git+https://github.com/Programvareverkstedet/grzegorz_clients.git#master pip install --user git+https://github.com/Programvareverkstedet/grzegorz_clients.git#master
grzegorz-webui --host 0.0.0.0 --port 80 grzegorz-webui --host-name 0.0.0.0 --port 80
It's rather insecure and could use a reverse proxy and some whitelisting. ;) It's rather insecure and could use a reverse proxy and some whitelisting. ;)

View File

@ -19,6 +19,7 @@ def request_delete(func):
url, data = func(*args, **kwargs) url, data = func(*args, **kwargs)
if type(data) is dict: data = json.dumps(data) if type(data) is dict: data = json.dumps(data)
response = requests.delete(f"{BASE_URL}/{url}", data=data) response = requests.delete(f"{BASE_URL}/{url}", data=data)
response.raise_for_status() # raises HTTPError of any
data = json.loads(response.text) data = json.loads(response.text)
if "error" not in data or data["error"] != False: if "error" not in data or data["error"] != False:
print(data) print(data)
@ -31,6 +32,7 @@ def request_post(func):
url, data = func(*args, **kwargs) url, data = func(*args, **kwargs)
if type(data) is dict: data = json.dumps(data) if type(data) is dict: data = json.dumps(data)
response = requests.post(f"{BASE_URL}/{url}", data=data) response = requests.post(f"{BASE_URL}/{url}", data=data)
response.raise_for_status() # raises HTTPError of any
data = json.loads(response.text) data = json.loads(response.text)
if "error" not in data or data["error"] != False: if "error" not in data or data["error"] != False:
print(data) print(data)
@ -42,6 +44,7 @@ def request_get(func):
def new_func(*args, **kwargs): def new_func(*args, **kwargs):
url = func(*args, **kwargs) url = func(*args, **kwargs)
response = requests.get(f"{BASE_URL}/{url}") response = requests.get(f"{BASE_URL}/{url}")
response.raise_for_status() # raises HTTPError of any
data = json.loads(response.text) data = json.loads(response.text)
if "error" not in data or data["error"] != False: if "error" not in data or data["error"] != False:
raise APIError(data["errortext"]) raise APIError(data["errortext"])