Up till now we've been dealing with running this stuff as a sidebar on spreadsheet.
Now we'll take the example in Parallel implementation and getting started - doing some cryptography exercises in parallel and run it as a web app. You could add a bunch of parameters to this - even passing an entire profile as a parameter, but for simplicity we'll just set up a default profile and use that.
I'm going to use the same script as I used in Parallel implementation and getting started, but add a doGet() function to handle the webapp functionality, and publish it. It's just a few lines. function doGet(e) { return worker (cryptoProfile(25,false)); } function worker (profile) { var htmlName = 'asyncService'; var html = HtmlService.createTemplateFromFile(htmlName) .evaluate() .getContent(); html += "<script>\n" + "doSomeThings( " + JSON.stringify(profile) + ");\n</script>"; return HtmlService.createTemplate(html).evaluate() .setSandboxMode(HtmlService.SandboxMode.NATIVE); } As you've been reading this, I've been running a bunch of parallel cryptographic tasks in the Apps Script cloud. See below for progress. You'll see that we got through about 1 minutes worth of work in about 20 seconds. For more on this topic, see Running things in parallel using HTML service. For more snippets like this see Google Apps Scripts snippets For help and more information join our forum,follow the blog or follow me on twitter .
|
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Google Apps Script HTML service > Running things in parallel using HTML service >