| import requests | |
| import os | |
| url = "http://localhost:8000/api/report/" | |
| payload = { | |
| "text": "Verification text for PDF report generation.", | |
| "score": 99.9, | |
| "label": "AI Generated" | |
| } | |
| try: | |
| print("Requesting PDF report...") | |
| response = requests.post(url, json=payload) | |
| if response.status_code == 200: | |
| content_size = len(response.content) | |
| print(f"Success! Received {content_size} bytes.") | |
| # Check for PDF header | |
| if response.content.startswith(b"%PDF"): | |
| print("Valid PDF header found.") | |
| with open("verification_report.pdf", "wb") as f: | |
| f.write(response.content) | |
| print("Saved 'verification_report.pdf' for inspection.") | |
| else: | |
| print("ERROR: Response is not a valid PDF (missing header).") | |
| else: | |
| print(f"Failed with Status Code: {response.status_code}") | |
| print(response.text) | |
| except Exception as e: | |
| print(f"Connection Error: {e}") | |