Skip to content

Commit a76b62f

Browse files
authored
Update tutorial-azure-function.md
1 parent b0992b3 commit a76b62f

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

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

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -187,36 +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"]
197-
198-
wait_sec = 25
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"]
199197
200-
time.sleep(wait_sec)
201-
# The layout API is async therefore the wait statement
198+
wait_sec = 25
202199
203-
resp =requests.get(url = get_url, headers = {"Ocp-Apim-Subscription-Key": apim_key})
200+
time.sleep(wait_sec)
201+
# The layout API is async therefore the wait statement
204202
205-
resp_json = json.loads(resp.text)
203+
resp = requests.get(url=get_url, headers={"Ocp-Apim-Subscription-Key": apim_key})
206204
205+
resp_json = json.loads(resp.text)
207206
208-
status = resp_json["status"]
207+
status = resp_json["status"]
209208
209+
if status == "succeeded":
210+
print("POST Layout Analysis succeeded:\n%s")
211+
results = resp_json
212+
else:
213+
print("GET Layout results failed:\n%s")
214+
quit()
210215
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()
216+
results = resp_json
217217
218-
results=resp_json
219-
```
218+
```
220219

221220
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.
222221

0 commit comments

Comments
 (0)