LoginSignup
1

More than 3 years have passed since last update.

G Suite(Google Apps Script)で、HTMLページを開発

Last updated at Posted at 2019-12-04

GASでHTMLを表示させるアプリケーションを作成

スクリプトエディタを開く

1.G Suiteにログインした状態で、script.google.com にアクセス
2.[新しいプロジェクト]をクリックして、スクリプトエディタを開く
3.プロジェクト名をつける

コードを編集

1.ファイル[コード.gs]を開いて、以下のコードをコピーして上書きする。

コード.gs
function doGet() {
  var html = HtmlService.createTemplateFromFile("index").evaluate();
  return html;
}

2.[ファイル]>[New]>[HTMLファイル]とクリックして、ファイル名を[index.html]として保存
3.

部分に<?!= Session.getActiveUser().getEmail();?>を追記する。
完成イメージ[index.html]
<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <?!= Session.getActiveUser().getEmail();?>
  </body>
</html>

ウェブアプリケーションとして公開

1.[公開]>[ウェブアプリケーションとして導入]をクリックして、ファイル名を[index.html]として保存

Execute the app as:Me
Who has access to the app:Only myself

2.[Deply]ボタンをクリック[latest code]というリンクが表示されるのでそこをクリックすると最新のウェブアプリケーションを確認できます。

3.ログインしたユーザーのメールアドレスが表示されていれば成功

参考

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1