import requests import sys def test_ocr(file_path): url = "http://localhost:8000/ocr" try: with open(file_path, "rb") as f: files = {"file": f} print(f"Sending {file_path} to {url}...") response = requests.post(url, files=files) if response.status_code == 200: print("Success!") data = response.json() print("Text Preview:", data["text"][:200], "...") print(f"Total Pages: {len(data['pages'])}") else: print(f"Error {response.status_code}: {response.text}") except FileNotFoundError: print(f"File not found: {file_path}") except Exception as e: print(f"Request failed: {e}") if __name__ == "__main__": if len(sys.argv) < 2: print("Usage: python test_client.py ") else: test_ocr(sys.argv[1])