IMTheNachoMan
IMTheNachoMan

Reputation: 5811

render HTML file in Drive in a Google Apps Script web app

I have an .html file in Google Drive. Is it possible to use it with HtmlService?

I know this code will render the Index.html file within the project.

function doGet() {
    return HtmlService.createHtmlOutputFromFile('Index');
}

But how can I get it to render a file that is in Google Drive?

My idea is that users would collaborate on an .html file outside of the web-app and the web-app would render t.

Upvotes: 3

Views: 931

Answers (1)

Tanaike
Tanaike

Reputation: 201368

  • You want to deploy Web Apps using HTML data retrieved from the file on your Google Drive.

If my understanding is correct, how about this modification? The flow of this modified script is as follows.

  1. Retrieve HTML data from a file on Google Drive.
  2. Web Apps is deployed using the HTML data.

Modified script:

function doGet() {
  var fileId = "###"; // Please set the fileID of HTML file on Google Drive.

  var html = DriveApp.getFileById(fileId).getBlob().getDataAsString();
  return HtmlService.createHtmlOutput(html);
}

Note:

  • By this, when the HTML is modified, HTML of Web Apps is also modified without redeploying as new version. Because the script of Google Apps Script is not changed.
  • But when you modified your script of Google Apps Script, please deploy Web Apps as new version again. By this, the latest script is reflected to Web Apps.

References:

If I misunderstood your question, I apologize.

Upvotes: 5

Related Questions