File size: 1,131 Bytes
4b6b17e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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)