File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 1515endpoint = os .environ ['BING_SEARCH_V7_ENDPOINT' ] + '/bing/v7.0/images/visualsearch'
1616subscription_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
2021headers = {'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
2425try :
2526 response = requests .post (endpoint , headers = headers , files = file )
2627 response .raise_for_status ()
28+
29+ print ("\n Headers:\n " )
30+ print (response .headers )
31+
32+ print ("\n JSON Response:\n " )
2733 pprint (response .json ())
2834except Exception as ex :
2935 raise ex
30-
You can’t perform that action at this time.
0 commit comments