Skip to content

Instantly share code, notes, and snippets.

@angelwong
Created March 8, 2017 18:13
Show Gist options
  • Save angelwong/46189e6ca48e5ce251215b380309a34b to your computer and use it in GitHub Desktop.
Save angelwong/46189e6ca48e5ce251215b380309a34b to your computer and use it in GitHub Desktop.
Include these methods in the "httpMethods.gs" file of the "Script editor" of your Google Spreadsheet Bot
/*
* Handle a GET request
*
* @param { Object } e - The request object https://developers.google.com/apps-script/guides/web#url_parameters
*/
function doGet(e) {
return ContentService.createTextOutput(
JSON.stringify(lookupAndCompute(null, e.parameter.text))
).setMimeType(ContentService.MimeType.JSON);
}
/*
* Handle a POST request
*
* @param { Object } e - The request object https://developers.google.com/apps-script/guides/web#url_parameters
*/
function doPost(e) {
try {
var body = JSON.parse(e.postData.contents);
return ContentService.createTextOutput(
JSON.stringify(lookupAndCompute(null, body.text, body.vars))
).setMimeType(ContentService.MimeType.JSON);
} catch(e) {
return ContentService.createTextOutput(
JSON.stringify({ error: e })
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment