Skip to content

Commit 0275e81

Browse files
committed
update python
1 parent a76b62f commit 0275e81

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

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

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -187,35 +187,36 @@ 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
190+
```python
191191
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"]
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
207-
status = resp_json["status"]
206+
resp_json = json.loads(resp.text)
208207
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()
208+
status = resp_json["status"]
215209
216-
results = resp_json
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()
217216
218-
```
217+
results = resp_json
218+
219+
```
219220
220221
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.
221222

0 commit comments

Comments
 (0)