-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_backend.py
More file actions
38 lines (32 loc) · 1.09 KB
/
test_backend.py
File metadata and controls
38 lines (32 loc) · 1.09 KB
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
import requests
import json
def test_backend():
"""Test the backend classification endpoint"""
# Test data - simple tree
test_edges = [
["A", "B"],
["B", "C"],
["B", "D"]
]
try:
# Test classification endpoint
response = requests.post('http://localhost:5000/classify',
json={'edges': test_edges},
timeout=10)
if response.status_code == 200:
result = response.json()
print("✅ Backend is working!")
print(f"Classification result: {json.dumps(result, indent=2)}")
return True
else:
print(f"❌ Backend error: {response.status_code}")
return False
except requests.exceptions.ConnectionError:
print("❌ Cannot connect to backend. Make sure it's running on port 5000")
return False
except Exception as e:
print(f"❌ Error: {e}")
return False
if __name__ == "__main__":
print("Testing backend connection...")
test_backend()