HtmlService can be used to render HTML content in response to HTTP requests to a published Apps Script web app. In this case, the Apps Script service is acting as web server. In addition to the web apps HTML capability, Apps Script can also serve up data as JSON (or JSONP), as well as XML and other formats. This allows you to create Apps Script apps that act as if they were a REST API, serving up processed data in response to query requests.
Just as with
ContentService apps must be published as a web app, contain a
doPost function to handle requests, and return results processed not by the
HtmlService class, but by
It is possible to convert any script (even a container-bound one) into a published web app that can serve data through
ContentService in response to HTTP queries, or content as HTML pages through
HtmlService. These important capabilities mean that you can make visible the full power of scripting, and the data it can access, for consumption by a browser or some cooperating process.
ContentService class can be used to expose Apps data such as spreadsheet content, calendar data, and JDBC database queries—in fact, anything processed with Apps Script can be published.
The Execution API was released recently, and you should consider it as an alternative when planning to use
ContentService to create a private API to execute Apps Script functions. You ...