Skip to content

Commit 203f116

Browse files
Merge pull request #214731 from laujan/patch-162
Update tutorial-azure-function.md
2 parents 93857fc + 0275e81 commit 203f116

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

articles/applied-ai-services/form-recognizer/tutorial-azure-function.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -187,35 +187,35 @@ Next, you'll add your own code to the Python script to call the Form Recognizer
187187
188188
1. Next, add code to query the service and get the returned data.
189189
190-
```Python
191-
resp = requests.post(url = post_url, data = source, headers = headers)
192-
if resp.status_code != 202:
193-
print("POST analyze failed:\n%s" % resp.text)
194-
quit()
195-
print("POST analyze succeeded:\n%s" % resp.headers)
196-
get_url = resp.headers["operation-location"]
190+
```python
191+
resp = requests.post(url=post_url, data=source, headers=headers)
197192
198-
wait_sec = 25
193+
if resp.status_code != 202:
194+
print("POST analyze failed:\n%s" % resp.text)
195+
quit()
196+
print("POST analyze succeeded:\n%s" % resp.headers)
197+
get_url = resp.headers["operation-location"]
199198
200-
time.sleep(wait_sec)
201-
# The layout API is async therefore the wait statement
199+
wait_sec = 25
202200
203-
resp =requests.get(url = get_url, headers = {"Ocp-Apim-Subscription-Key": apim_key})
201+
time.sleep(wait_sec)
202+
# The layout API is async therefore the wait statement
204203
205-
resp_json = json.loads(resp.text)
204+
resp = requests.get(url=get_url, headers={"Ocp-Apim-Subscription-Key": apim_key})
206205
206+
resp_json = json.loads(resp.text)
207207
208-
status = resp_json["status"]
208+
status = resp_json["status"]
209209
210+
if status == "succeeded":
211+
print("POST Layout Analysis succeeded:\n%s")
212+
results = resp_json
213+
else:
214+
print("GET Layout results failed:\n%s")
215+
quit()
210216
211-
if status == "succeeded":
212-
print("POST Layout Analysis succeeded:\n%s")
213-
results=resp_json
214-
else:
215-
print("GET Layout results failed:\n%s")
216-
quit()
217+
results = resp_json
217218
218-
results=resp_json
219219
```
220220
221221
1. Add the following code to connect to the Azure Storage **output** container. Fill in your own values for the storage account name and key. You can get the key on the **Access keys** tab of your storage resource in the Azure portal.

0 commit comments

Comments
 (0)