Welding files in appscripts
# Trending # Drug sign with lemon8 # appscript # Web Site Writing Basics # Weld the file
Connecting files to write web apps with Google Apps Script can be done in two main ways, each with different advantages and limitations:
1.File welding using HTML Service (for complex and interactive UI)
This method creates separate HTML, CSS and JavaScript files and then "serves" them through Google Apps Script to create a complex and interactive User Interface like a common web application.
Principles of work:
You will create an HTML file (such as index.html, sidebar.html) within your Apps Script project.
In these HTML files, you can write HTML, CSS, and JavaScript code to design the face and operation of the UI.
Google Apps Script will act as a "server" to deliver these HTML files to the user's browser.
JavaScript located in an HTML file can call the Apps Script (Server-side) side function through google.script.run to retrieve or process data.
Apps Script can send data back to Client-side JavaScript to update the UI.
Advantages:
High flexibility: Able to create a beautiful, complex and gimmicked UI like a typical web application.
Real-time interaction: Client-side JavaScript can interact with users and run Server-side functions smoothly.
Explicit fragmentation: HTML, CSS, JavaScript and Apps Script (Backyard) code are separated, simplifying management and maintenance.
Restrictions:
More complex: Requires basic knowledge of HTML, CSS and JavaScript.
Debugging: Debugging Client-side JavaScript code can be more complicated.
Performance: If too much data is sent between Client-side and Server-side, it may affect performance somewhat.
Example of use:
Create a fill-in form with Real-time authentication.
Create a Dashboard, display data graphically
Create an application with multiple pages of navigation.
2.Welding files using Content Service (for raw data or simple content)
This method is to use Google Apps Script to return raw text content (Plain Text), JSON, CSV, or XML directly to a user or other application, suitable for cases where you want to serve raw data or create a simple API.
Principles of work:
You will use the doGet () or doPost () functions in the .gs file (Apps Script) to handle HTTP requests.
Instead of returning an entire page of HTML, you will use ContentService.createTextOutput () to create textual output.
You can define a MIME type, such as MimeType.JSON for JSON or MimeType.TEXT for plain text.
Suitable for creating APIs that external applications can run to receive data.
Advantages:
Easy to use: No need to write Client-side HTML, CSS or JavaScript code
High Performance: Because it returns raw data, it does not require complex UI processing.
Suitable for APIs: Create a Web API that other applications can easily run.
Restrictions:
Limited UI: Complex user interface cannot be created directly from the Content Service.
Limited Interaction: Interaction with the user must be done through an external application that runs the API.
Example of use:
Create an API for retrieving data from Google Sheet in JSON format.
Create a service for saving data sent from external forms into Google Sheet.
Create a Webhook for receiving data from other services.




































































































