File size: 1,478 Bytes
0277cf5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import requests

BASE_URL = "https://miya3333-getusergamedatatest.hf.space"

def call_get_hello():
    response = requests.get(f"{BASE_URL}/")
    if response.status_code == 200:
        print("GET / response:", response.json())
    else:
        print(f"GET / failed with status code: {response.status_code}")
        print("Response text:", response.text)

def call_post_hello(name: str):
    response = requests.post(f"{BASE_URL}/?name={name}")
    if response.status_code == 200:
        print(f"POST / with name '{name}' response:", response.json())
    else:
        print(f"POST / with name '{name}' failed with status code: {response.status_code}")
        print("Response text:", response.text)

def call_get_ranking():
    response = requests.get(f"{BASE_URL}/ranking")
    if response.status_code == 200:
        print("GET /ranking response:", response.json())
    else:
        print(f"GET /ranking failed with status code: {response.status_code}")
        print("Response text:", response.text)

def call_get_userdata():
    response = requests.get(f"{BASE_URL}/userdata")
    if response.status_code == 200:
        print("GET /userdata response:", response.json())
    else:
        print(f"GET /userdata failed with status code: {response.status_code}")
        print("Response text:", response.text)

if __name__ == "__main__":
    call_get_hello()
    call_post_hello("World")
    call_post_hello("FastAPI User")
    call_get_ranking()
    call_get_userdata()