0

So, my question seems confuse at first because I can't find any direct reference about doGet() and doPost(), I can find it on specific documentations like the webApp one so I am having hard time grasping how doGet() works, that said...

function doGet(request) {
  return HtmlService.createTemplateFromFile('INTERFACE/INICIAR/AcessoHTML')
      .evaluate();
}

I am using the code above to start my webApp, I have two doubts here:

  1. This will start the landing page of the webApp (A login page), how can I change the page after the login? (point out to another html. I know I can use createTemplateFromFile and evaluate() to generate the page itself

  2. doGet() is used to access the params of an HTML form, right? But I am returning the html page here, from what I found I would need to return the params I get from the submitted form but I am already returning another thing and as far I know you cannot have two return in the same function nor two doGet() on the same project.

1 Answers1

0

Multiple pages:

You can query the webapp URL with certain request parameters, for example:

const url = ScriptApp.getService().getUrl();
const paramUrl = `${url}?path=afterLogin`;

Now accessing this paramUrl will fire the doGet function, and the request parameters (path=afterLogin) will be accessible through the doGet function argument.

Here's a very simple example:

function doGet(e) {
  if (e.parameter["path"] === "afterLogin") {
    return HtmlService.createTemplateFromFile('AFTER_LOGIN_HTML_FILE').evaluate();
  } else {
    return HtmlService.createTemplateFromFile('INTERFACE/INICIAR/AcessoHTML').evaluate();
  }
}

Reference:

Iamblichus
  • 18,540
  • 2
  • 11
  • 27