import os import requests hordeApiKey = os.environ.get("HORDE_API_KEY") baseUrl = "https://aihorde.net/api/v2/" def getResponseByGet(url): headers = { "Content-Type": "application/json", "apikey": f"{hordeApiKey}" } response = requests.get(url, headers=headers) if response.status_code == 200: return response.json() else: return { "code": response.status_code, "reason": response.reason } def getResponseByPost(url): headers = { "Content-Type": "application/json", "apikey": f"{hordeApiKey}" } response = requests.post(url, headers=headers) if response.status_code == 200: return response.json() else: return { "code": response.status_code, "reason": response.reason } def getUserDetails(): url = f"{baseUrl}find_user" return getResponseByPost(url) def generateCheck(id): url = f"{baseUrl}generate/check/{id}" return getResponseByGet(url) def generateStatus(id): url = f"{baseUrl}generate/status/{id}" return getResponseByGet(url)