Spaces:
Sleeping
Sleeping
Download test_client.py from zasprince8/quickpdf-ocr: direct link, hf CLI and curl.
- Browser
- Download file 924 Bytes
-
https://huggingface.co/spaces/zasprince8/quickpdf-ocr/resolve/main/test_client.py
- Command line
-
hf download hf://spaces/zasprince8/quickpdf-ocr/test_client.py
-
curl -L -o test_client.py https://huggingface.co/spaces/zasprince8/quickpdf-ocr/resolve/main/test_client.py
924 Bytes
| 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 <path_to_file>") | |
| else: | |
| test_ocr(sys.argv[1]) | |