File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 1+ import os
2+
13from azure .cognitiveservices .search .autosuggest import AutoSuggestClient
24from azure .cognitiveservices .search .autosuggest .models import (
35 Suggestions ,
810from msrest .authentication import CognitiveServicesCredentials
911
1012# Add your Bing Autosuggest subscription key to your environment variables.
11- SUBSCRIPTION_KEY = os .environ ['BING_AUTOSUGGEST_SUBSCRIPTION_KEY' ]
12-
13+ SUBSCRIPTION_KEY = os .environ ['BING_AUTOSUGGEST_SUBSCRIPTION_KEY' ]
14+ ENDPOINT = os . environ [ 'BING_AUTOSUGGEST_ENDPOINT' ]
1315
1416def autosuggest_lookup (subscription_key ):
1517 """AutoSuggestLookup.
1618
1719 This will look up a single query (Xbox) and print out name and url for first web result.
1820 """
1921 client = AutoSuggestClient (
20- endpoint = "https://api.cognitive.microsoft.com" ,
22+ endpoint = ENDPOINT ,
2123 credentials = CognitiveServicesCredentials (subscription_key )
2224 )
2325
@@ -49,7 +51,7 @@ def error(subscription_key):
4951
5052 # Breaking the subscription key on purpose
5153 client = AutoSuggestClient (
52- endpoint = "https://api.cognitive.microsoft.com" ,
54+ endpoint = ENDPOINT ,
5355 credentials = CognitiveServicesCredentials (subscription_key + "1" )
5456 )
5557
You can’t perform that action at this time.
0 commit comments