Last active
May 24, 2021 01:02
-
-
Save moisutsu/6d5b1721d4c4e4aa7e6184f2a6f557d5 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
// 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