GetUserGameDataTest / client.py
miya3333's picture
Upload client.py
0277cf5 verified
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()