Reputation: 941
I've always thought that when you create a Web App with GAS (using Html Service), the codes you write in Code.gs and HTML file(s) are both client-side codes.
But from this Html Service: Communicate with server functions guide, it seems to imply that the codes in Code.gs is "server-side" and the codes in index.html is "client side".
The guide states that "the function deepSecret_() is completely invisible to the client." If that is the case, the client-side codes is only the index.html file right? So I am actually writing both server and client codes when creating Web App?
I guess what confuses me is that I am under the assumption that when creating Web App with GAS I am just writing "client-side" code.
Upvotes: 1
Views: 887
Reputation: 6184
If you read through the docs it becomes apparent that code.gs is code running on Google's servers. It's not completely spelled out other than a few places where it states "in the cloud."
The basic idea is that your code.gs uses either the Html Service or the UI Service. In the case of the Html Service, the script runs server side to serve html to the user's browser. It also defines functions that are run on the server.
The html sent to the user can contain javascript calls that use Google's client library to provide linkage back to the server defined method. In the example you posted, It is running the getBankBalance() method on the server and then the user's browser will run the callback function onSuccess() if the call to the server successfully returns.
Upvotes: 4