I have a Python Flask app on my laptop that successfully accesses the Watson Language Translator on Bluemix precisely as described in the Bluemix API Documentation
from watson_developer_cloud import LanguageTranslatorV2 as LanguageTranslator
language_translator = LanguageTranslator(
username='4e93f965-f1ab-407c-a502-xxxxxx',
password='3zUExxxxxx')
translation = language_translator.translate(
text='hello there, this is a test',
source='en', target='fr')
print(json.dumps(translation, indent=2, ensure_ascii=False))
I now want to move my Python Flask app to Bluemix and access the Language Translator service totally within Bluemix. So I can no longer use from watson_developer_cloud import LanguageTranslatorV2 as LanguageTranslator
Precisely how do I access the Language Translation Service within Bluemix using the Language Translation Service credentials?
When running python on Bluemix (or most other cloud hosting providers), the standard way of defining dependencies is via a requirements.txt
file. The bluemix server runs commands to read this file and install the dependencies listed there.
You can see complete documentation at https://pip.pypa.io/en/stable/user_guide/#requirements-files but the basic version is just a file with one line like so:
watson-developer-cloud
Take a look at https://github.com/watson-developer-cloud?utf8=%E2%9C%93&q=python&type=&language=python for several example python apps which use watson-developer-cloud
and can be deployed to bluemix.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.