File tree Expand file tree Collapse file tree 1 file changed +0
-12
lines changed
Expand file tree Collapse file tree 1 file changed +0
-12
lines changed Original file line number Diff line number Diff line change 1010
1111import os , requests , uuid , json
1212
13- # Checks to see if the Translator Text subscription key is available
14- # as an environment variable. If you are setting your subscription key as a
15- # string, then comment these lines out.
16- if 'TRANSLATOR_TEXT_KEY' in os .environ :
17- subscriptionKey = os .environ ['TRANSLATOR_TEXT_KEY' ]
18- else :
19- print ('Environment variable for TRANSLATOR_TEXT_KEY is not set.' )
20- exit ()
21- # If you want to set your subscription key as a string, uncomment the next line.
22- #subscriptionKey = 'put_your_key_here'
23-
2413# If you encounter any issues with the base_url or path, make sure
2514# that you are using the latest endpoint: https://docs.microsoft.com/azure/cognitive-services/translator/reference/v3-0-languages
2615base_url = 'https://api.cognitive.microsofttranslator.com'
2716path = '/languages?api-version=3.0'
2817constructed_url = base_url + path
2918
3019headers = {
31- 'Ocp-Apim-Subscription-Key' : subscriptionKey ,
3220 'Content-type' : 'application/json' ,
3321 'X-ClientTraceId' : str (uuid .uuid4 ())
3422}
You can’t perform that action at this time.
0 commit comments