-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug_response.py
More file actions
39 lines (34 loc) · 1.22 KB
/
debug_response.py
File metadata and controls
39 lines (34 loc) · 1.22 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
"""
Quick debug script to test API response format
"""
import requests
import json
print("="*60)
print("DEBUG: Testing API Response Format")
print("="*60)
# Test with the exact same text from the test page
response = requests.post(
"http://localhost:8000/analyze",
json={
"text": "LAST CHANCE! Cookie Notice Only 127 people can accept this offer today! Accept all cookies now to unlock exclusive features instantly!",
"buttons": ["ACCEPT ALL COOKIES NOW!", "maybe later"]
}
)
print("\nStatus Code:", response.status_code)
print("\nFull Response:")
print(json.dumps(response.json(), indent=2))
data = response.json()
print("\n" + "="*60)
print("KEY CHECKS:")
print("="*60)
print(f"has 'is_dark_pattern' key: {('is_dark_pattern' in data)}")
print(f"value of is_dark_pattern: {data.get('is_dark_pattern')}")
print(f"type of is_dark_pattern: {type(data.get('is_dark_pattern'))}")
print(f"is it exactly True: {data.get('is_dark_pattern') == True}")
print(f"is it truthy: {bool(data.get('is_dark_pattern'))}")
print("\n" + "="*60)
print("EXPECTED IN EXTENSION:")
print("="*60)
print("if (response && response.is_dark_pattern === true) {")
print(f" // Would trigger: {data.get('is_dark_pattern') == True}")
print("}")