File size: 793 Bytes
73b49a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import requests

url = 'http://localhost:7860/api/v1/extract'
pdf_path = "pdfs/Enfothelial dysfunction.pdf"

try:
    with open(pdf_path, 'rb') as f:
        files = {'file': f}
        response = requests.post(url, files=files)
        
    print(f"Status Code: {response.status_code}")
    print(f"Response Headers: {response.headers}")
    print(f"Response Text: {response.text}")
    
    if response.ok:
        print("JSON Response:", response.json())
    else:
        print(f"Error: {response.text}")
except FileNotFoundError:
    print(f"Error: Could not find PDF file at {pdf_path}")
except requests.exceptions.ConnectionError:
    print(f"Error: Could not connect to server at {url}. Make sure the server is running.")
except Exception as e:
    print(f"Unexpected error: {str(e)}")