Skip to content

Instantly share code, notes, and snippets.

@moisutsu
Last active May 24, 2021 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moisutsu/6d5b1721d4c4e4aa7e6184f2a6f557d5 to your computer and use it in GitHub Desktop.
Save moisutsu/6d5b1721d4c4e4aa7e6184f2a6f557d5 to your computer and use it in GitHub Desktop.
// modify https://qiita.com/satto_sann/items/be4177360a0bc3691fdf
function doPost(e) {
const params = JSON.parse(e.postData.getDataAsString());
const translated_text = LanguageApp.translate(params.text, params.source, params.target);
let body;
if (translated_text) {
body = {
code: 200,
text: translated_text
};
} else {
body = {
code: 400,
text: "Bad Request"
};
}
let response = ContentService.createTextOutput();
response.setMimeType(ContentService.MimeType.JSON);
response.setContent(JSON.stringify(body));
return response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment