diff --git a/README.md b/README.md index f9d315c..7c2fe96 100644 --- a/README.md +++ b/README.md @@ -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: 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. ;) diff --git a/grzegorz_clients/api.py b/grzegorz_clients/api.py index 9202956..a4b8100 100644 --- a/grzegorz_clients/api.py +++ b/grzegorz_clients/api.py @@ -19,6 +19,7 @@ def request_delete(func): url, data = func(*args, **kwargs) if type(data) is dict: data = json.dumps(data) response = requests.delete(f"{BASE_URL}/{url}", data=data) + response.raise_for_status() # raises HTTPError of any data = json.loads(response.text) if "error" not in data or data["error"] != False: print(data) @@ -31,6 +32,7 @@ def request_post(func): url, data = func(*args, **kwargs) if type(data) is dict: data = json.dumps(data) response = requests.post(f"{BASE_URL}/{url}", data=data) + response.raise_for_status() # raises HTTPError of any data = json.loads(response.text) if "error" not in data or data["error"] != False: print(data) @@ -42,6 +44,7 @@ def request_get(func): def new_func(*args, **kwargs): url = func(*args, **kwargs) response = requests.get(f"{BASE_URL}/{url}") + response.raise_for_status() # raises HTTPError of any data = json.loads(response.text) if "error" not in data or data["error"] != False: raise APIError(data["errortext"])