forked from nupurmadaan04/SOUL_SENSE_EXAM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiagnose_connection.py
More file actions
30 lines (27 loc) · 963 Bytes
/
diagnose_connection.py
File metadata and controls
30 lines (27 loc) · 963 Bytes
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
import http.client
import json
def check_backend():
print("Checking backend at 127.0.0.1:8000...")
try:
conn = http.client.HTTPConnection("127.0.0.1", 8000, timeout=10)
conn.request("GET", "/api/v1/health")
resp = conn.getresponse()
data = resp.read().decode()
print(f"Status: {resp.status}")
print(f"Response: {data}")
conn.close()
except Exception as e:
print(f"Error connecting to 127.0.0.1:8000: {e}")
print("\nChecking CAPTCHA endpoint...")
try:
conn = http.client.HTTPConnection("127.0.0.1", 8000, timeout=10)
conn.request("GET", "/api/v1/auth/captcha")
resp = conn.getresponse()
data = resp.read().decode()
print(f"Status: {resp.status}")
print(f"Response: {data}")
conn.close()
except Exception as e:
print(f"Error connecting to CAPTCHA endpoint: {e}")
if __name__ == "__main__":
check_backend()