Skip to content

Commit 68ed0c9

Browse files
committed
Fixed code samples
1 parent af5e01f commit 68ed0c9

File tree

1 file changed

+6
-1
lines changed
  • learn-pr/wwl-data-ai/analyze-content-ai-api/includes

1 file changed

+6
-1
lines changed

learn-pr/wwl-data-ai/analyze-content-ai-api/includes/04-analyze.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ For example, suppose you want to use the business card analyzer discussed previo
99
The following Python code submits a request for analysis, and then polls the service until the operation is complete and the results are returned.
1010

1111
```python
12-
analyzer_name = "business_card_analyser"
12+
import json
13+
import requests
1314

1415
# Read the image data
1516
with open("business-card.png", "rb") as file:
1617
image_data = file.read()
1718

1819
## Use a POST request to submit the image data to the analyzer
20+
analyzer_name = "business_card_analyser"
21+
1922
headers = {
2023
"Ocp-Apim-Subscription-Key": "<YOUR_API_KEY>",
2124
"Content-Type": "application/octet-stream"}
@@ -203,6 +206,8 @@ Here's the complete JSON response for the business card analysis:
203206
Your application must typically parse the JSON to retrieve field values. For example, the following python code extracts all of the *string* values:
204207

205208
```python
209+
# (continued from previous code example)
210+
206211
# Iterate through the fields and extract the names and type-specific values
207212
contents = result_json["result"]["contents"]
208213
for content in contents:

0 commit comments

Comments
 (0)