-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
30 lines (23 loc) · 888 Bytes
/
test.py
File metadata and controls
30 lines (23 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import requests
# Endpoint of the API
url="http://127.0.0.1:8000/document_classification"
############################## Test the API with a URL #############################
payload = {"url_path": "https://dagrs.berkeley.edu/sites/default/files/2020-01/sample.pdf"}
response = requests.post(url, params=payload)
# Handle the response
if response.status_code == 200:
# Request successful
print(response.json())
else:
# Request failed
print("Error:", response.status_code)
############################## Test the API with a local file #############################""
files = {"file": open("a path to your local file .pdf, .jpeg, .png, .jpg",'rb')}
response = requests.post(url, files=files)
# Handle the response
if response.status_code == 200:
# Request successful
print(response.json())
else:
# Request failed
print("Error:", response.status_code)