Created
March 8, 2017 18:13
-
-
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
This file contains hidden or 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
/* | |
* 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