Skip to content

Commit 84e3a3e

Browse files
authored
Updated library
1 parent f2285ca commit 84e3a3e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

python/Search/BingVisualSearchv7.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,21 @@
1515
endpoint = os.environ['BING_SEARCH_V7_ENDPOINT'] + '/bing/v7.0/images/visualsearch'
1616
subscription_key = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY']
1717

18-
image_path = 'YOUR-IMAGE.xxx' # for example: my_image.jpg
18+
image_path = 'MY-IMAGE' # for example: my_image.jpg
1919

20+
# Construct the request
2021
headers = {'Ocp-Apim-Subscription-Key': subscription_key}
21-
22-
file = {'image' : ('YOUR-IMAGE', open(image_path, 'rb'))} # YOUR-IMAGE is the name of the image file (no extention)
22+
file = {'image' : ('MY-IMAGE', open(image_path, 'rb'))} # MY-IMAGE is the name of the image file (no extention)
2323

24+
# Call the API
2425
try:
2526
response = requests.post(endpoint, headers=headers, files=file)
2627
response.raise_for_status()
28+
29+
print("\nHeaders:\n")
30+
print(response.headers)
31+
32+
print("\nJSON Response:\n")
2733
pprint(response.json())
2834
except Exception as ex:
2935
raise ex
30-

0 commit comments

Comments
 (0)