Saturday, February 11, 2017

Make a website with google apps script: Hello World

1. Go to google spreadsheet's website.


 2. Make a spreadsheet.


3. Click "Tools" from the menu and then click "Script editor."

4. You will see this will be displayed.

5. Add a html file called "index" as follows.


Now a html is added to your project.
Then change the html code as follows:
You can see "<h1>Hello World</h1>" was added to the original code.

7. Change the function on Code.gs to doGet() from nyFunction() as follows.

Namely, delete this code that had been written:
function myFunction() {

}

And copy and paste this code instead:
function doGet() {
    // This reads the html called "index".
    var html = HtmlService.createTemplateFromFile("index");

    // This takes HTML code and interprets it into what you see visually.
    return html.evaluate();
}

8. Save it.




9.  Click "Manage versions" from "File" tab.

Then, you will see this will be displayed. Write something in the box and click "Save New Version."

And a new version will be added.

10, Now click "Deploy as web app" from "Publish" tab.


11 This will be displayed. If you want to publish the web app to anyone (even for those who don't have google account), choose "Anyone, even anonymous" from "Who has access to the app." When you finish adjusting this setting, click "Deploy".

12, A URL to the web app will be shown. Copy the URL and access to this URL from your browser. This is the link for your web app.

13, Hello World!!!