Skip to content

Commit deac39a

Browse files
authored
Update Languages.py
1 parent db9144a commit deac39a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Languages.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
# You may need to install requests and uuid.
88
# Run: pip install requests uuid
99

10-
1110
import os, requests, uuid, json
1211

12+
endpoint_var_name = 'TRANSLATOR_TEXT_ENDPOINT'
13+
if not endpoint_var_name in os.environ:
14+
raise Exception('Please set/export the environment variable: {}'.format(endpoint_var_name))
15+
endpoint = os.environ[endpoint_var_name]
16+
1317
# If you encounter any issues with the base_url or path, make sure
1418
# that you are using the latest endpoint: https://docs.microsoft.com/azure/cognitive-services/translator/reference/v3-0-languages
15-
base_url = 'https://api.cognitive.microsofttranslator.com'
1619
path = '/languages?api-version=3.0'
17-
constructed_url = base_url + path
20+
constructed_url = endpoint + path
1821

1922
headers = {
2023
'Content-type': 'application/json',

0 commit comments

Comments
 (0)