-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathcheck_endpoints.py
More file actions
60 lines (52 loc) · 1.63 KB
/
Copy pathcheck_endpoints.py
File metadata and controls
60 lines (52 loc) · 1.63 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import urllib.request
import time
import json
import threading
import sys
import os
# Wait for server to start (manual or automated)
# For this script, we assume the server is running on localhost:5000
BASE_URL = "http://localhost:5000"
ENDPOINTS = [
'/user/profile',
'/user/history',
'/product/search',
'/admin/config',
'/data/matrix',
'/data/mixed_array',
'/edge/empty_response',
'/edge/null_root',
'/edge/large_payload',
'/edge/special_chars'
]
def check_endpoints():
print(f"Checking {len(ENDPOINTS)} endpoints on {BASE_URL}...")
success_count = 0
fail_count = 0
for ep in ENDPOINTS:
url = BASE_URL + ep
try:
with urllib.request.urlopen(url) as response:
status = response.status
body = response.read().decode('utf-8')
# Basic validation
if status == 200:
print(f"✅ {ep} [200 OK]")
# Peek at body if short
if len(body) < 100:
print(f" Body: {body}")
else:
print(f" Body: {body[:100]}... (truncated)")
success_count += 1
else:
print(f"❌ {ep} [{status}]")
fail_count += 1
except Exception as e:
print(f"❌ {ep} Error: {e}")
fail_count += 1
print(f"\n--- Summary ---")
print(f"Total: {len(ENDPOINTS)}")
print(f"Passed: {success_count}")
print(f"Failed: {fail_count}")
if __name__ == "__main__":
check_endpoints()