LEC 8 IOT Flashcards
(12 cards)
What is Google Apps Script (GAS)?
part of google suite ( cloud- based automation platform)
Uses JavaScript for scripting.
ability to extend google apps functionality (docs, sheets etc)
What are the three main types of GAS?
Standalone – Stored in Google Drive and runs independently.
Bounded - Embedded to google workspace document
Web apps - Provides execution access via a web browser; standalone & bound scripts can be converted into web apps.
What is the programming style of GAS?
Mainly JavaScript.
Uses camelCase for built-in objects and functions.
Object-oriented programming (OOP).
How does a GAS Web App work
Client (browser, mobile, PC) sends requests and receives responses.
Server (Google Cloud) runs the script and processes requests.
Uses the concept callback:
“Call” = Sending code to the server.
“Callback” = The result sent back from the server.
What are the two types of GAS deployment?
Test Deployment – Used for testing before actual release.
Actual Deployment – Generates a unique URL for web access.
Can be Private or Public.
What are the steps to create a Web App in GAS?
Write the script, including doGet(e) or doPost(e).
Activate via Test Deployment or Actual Deployment.
A unique URL is generated only after deployment.
What is the difference between doGet(e) and doPost(e)?
doGet(e): Handles GET requests (Fetching data).
Example use case: Displaying a webpage, retrieving data from Google Sheets.
doPost(e): Handles POST requests (Sending data).
Example use case: Submitting a form, storing IoT data in Google Sheets.
Example of a simple Web App using GAS (doGet function)
function doGet(e) {
return ContentService.createTextOutput(“Hello, Web App!”);
}
Example of a Web App that stores IoT data in Google Sheets (doPost function)
function doPost(e) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var data = JSON.parse(e.postData.contents);
sheet.appendRow([data.time, data.temperature, data.humidity]);
return ContentService.createTextOutput(“Data Saved”);
}
What is the hierarchy of Google SpreadSheets in GAS?
Workbook → Worksheet → Cells
Uses A1 notation to access specific cells.
What are some basic spreadsheet operations in GAS?
Get active spreadsheet:
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
Read from a cell:
var value = sheet.getRange(“A1”).getValue();
Logger.log(value);
Write to a cell:
sheet.getRange(“A1”).setValue(“New Data”);
Append data to a sheet:
sheet.appendRow([“Time”, “Temperature”, “Humidity”]);
What are the limitations of GAS?
Storage limitations – Limited execution time and storage space.
Server response time – Can have delays depending on workload.
Security restrictions – Only accepts secure connections.