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, "rc": response.rc } 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, "rc": response.rc } async def getUserDetails(): url = f"{baseUrl}find_user" return getResponseByGet(url) async def generateCheck(id): url = f"{baseUrl}generate/check/{id}" return getResponseByGet(url) async def generateStatus(id): url = f"{baseUrl}generate/status/{id}" return getResponseByGet(url)