Spaces:
Sleeping
Sleeping
| import os | |
| import requests | |
| import json | |
| # Target URL for your local running FastAPI instance | |
| URL = "http://127.0.0.1:8000/api/claims/adjudicate" | |
| # Pick one of the sample images available in your folder | |
| IMAGE_FILE = "111.jpg" # You can swap this with '111.jpg', '115.jpg', or 'handwriting.png' | |
| def run_test(): | |
| if not os.path.exists(IMAGE_FILE): | |
| print(f"β Error: Test image '{IMAGE_FILE}' not found in the root folder.") | |
| return | |
| print(f"π Sending claim adjudication request for document: {IMAGE_FILE}...") | |
| # Form fields required by our FastAPI route | |
| form_data = { | |
| "member_id": "Sudhan P", | |
| "claim_amount": "4500.00", | |
| "cashless_request": "false", | |
| "hospital_name": "Apollo Hospital" | |
| } | |
| # Open and attach the document image | |
| with open(IMAGE_FILE, "rb") as f: | |
| files = { | |
| "document": (IMAGE_FILE, f, "image/jpeg") | |
| } | |
| try: | |
| # Fire the multi-part form POST request | |
| response = requests.post(URL, data=form_data, files=files) | |
| print(f"Status Code: {response.status_code}\n") | |
| if response.status_code == 200: | |
| print("β Adjudication Success Response:") | |
| print(json.dumps(response.json(), indent=2)) | |
| else: | |
| print("β Server Error Response:") | |
| print(response.text) | |
| except requests.exceptions.ConnectionError: | |
| print("β Connection Error: Is your uvicorn server still running on port 8000?") | |
| if __name__ == "__main__": | |
| run_test() |