Add GET /api/teleporter

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2023-01-23 21:56:11 +01:00
parent 4c62a02026
commit 13168c377b
20 changed files with 266 additions and 61 deletions

View File

@@ -95,7 +95,7 @@ class FTLAPI():
self.session = response["session"]
# Query the FTL API (GET) and return the response
def GET(self, uri: str, params: List[str] = []):
def GET(self, uri: str, params: List[str] = [], expected_mimetype: str = "application/json"):
self.errors = []
try:
# Add parameters to the URI (if any)
@@ -113,7 +113,10 @@ class FTLAPI():
with requests.get(url = self.api_url + uri, json = data) as response:
if self.verbose:
print(json.dumps(response.json(), indent=4))
return response.json()
if expected_mimetype == "application/json":
return response.json()
else:
return response.content
except Exception as e:
self.errors.append("Exception when GETing from FTL: " + str(e))
return None