File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 1+ import json
2+ import requests
3+
4+ api_key = "my-api-key"
5+ account = "my-account"
6+ endpoint = "my-endpoint"
7+ version = "my-version"
8+
9+ url = f"https://api.mindee.net/v1/products/{account}/{endpoint}/v{version}/predict"
10+
11+ with open("/path/to/the/file.ext", "rb") as file_handle:
12+ files = {"document": file_handle}
13+ headers = {"Authorization": f"Token {api_key}"}
14+ response = requests.post(url, files=files, headers=headers)
15+
16+ json_response = response.json()
17+
18+ if not response.ok:
19+ raise RuntimeError(json_response["api_request"]["error"])
20+
21+ print(json.dumps(json_response["document"], indent=2))
Original file line number Diff line number Diff line change 1414 echo " ###############################################"
1515 echo
1616
17- sed " s/my-api-key/${API_KEY} /" " $f " > $OUTPUT_FILE
17+ sed " s/my-api-key/${API_KEY} /" " ${f} " > $OUTPUT_FILE
1818 sed -i ' s/\/path\/to\/the\/file.ext/.\/tests\/data\/pdf\/blank_1.pdf/' $OUTPUT_FILE
1919
2020 if echo " $f " | grep -q " custom_v1.txt"
2121 then
2222 sed -i " s/my-account/$ACCOUNT /g" $OUTPUT_FILE
2323 sed -i " s/my-endpoint/$ENDPOINT /g" $OUTPUT_FILE
2424 fi
25+
26+ if echo " ${f} " | grep -q " default.txt"
27+ then
28+ sed -i " s/my-account/$ACCOUNT /" $OUTPUT_FILE
29+ sed -i " s/my-endpoint/$ENDPOINT /" $OUTPUT_FILE
30+ sed -i " s/my-version/1/" $OUTPUT_FILE
31+ fi
32+
2533 python $OUTPUT_FILE
2634done
You can’t perform that action at this time.
0 commit comments