Created
December 7, 2019 20:43
-
-
Save andriyor/02e9e1e99b73c46187f541a9063bec8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from chalice import Chalice | |
from googletrans import Translator | |
app = Chalice(app_name='helloworld') | |
translator = Translator() | |
@app.route('/translate', methods=['POST'], cors=True) | |
def translate(): | |
user_as_json = app.current_request.json_body | |
text = user_as_json['text'] | |
language = user_as_json['language'] | |
trasnlated_text = translator.translate(text, dest=language).text | |
return trasnlated_text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment