miya3333 commited on
Commit
0277cf5
·
verified ·
1 Parent(s): 919a48f

Upload client.py

Browse files
Files changed (1) hide show
  1. client.py +42 -0
client.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+
3
+ BASE_URL = "https://miya3333-getusergamedatatest.hf.space"
4
+
5
+ def call_get_hello():
6
+ response = requests.get(f"{BASE_URL}/")
7
+ if response.status_code == 200:
8
+ print("GET / response:", response.json())
9
+ else:
10
+ print(f"GET / failed with status code: {response.status_code}")
11
+ print("Response text:", response.text)
12
+
13
+ def call_post_hello(name: str):
14
+ response = requests.post(f"{BASE_URL}/?name={name}")
15
+ if response.status_code == 200:
16
+ print(f"POST / with name '{name}' response:", response.json())
17
+ else:
18
+ print(f"POST / with name '{name}' failed with status code: {response.status_code}")
19
+ print("Response text:", response.text)
20
+
21
+ def call_get_ranking():
22
+ response = requests.get(f"{BASE_URL}/ranking")
23
+ if response.status_code == 200:
24
+ print("GET /ranking response:", response.json())
25
+ else:
26
+ print(f"GET /ranking failed with status code: {response.status_code}")
27
+ print("Response text:", response.text)
28
+
29
+ def call_get_userdata():
30
+ response = requests.get(f"{BASE_URL}/userdata")
31
+ if response.status_code == 200:
32
+ print("GET /userdata response:", response.json())
33
+ else:
34
+ print(f"GET /userdata failed with status code: {response.status_code}")
35
+ print("Response text:", response.text)
36
+
37
+ if __name__ == "__main__":
38
+ call_get_hello()
39
+ call_post_hello("World")
40
+ call_post_hello("FastAPI User")
41
+ call_get_ranking()
42
+ call_get_userdata()