がすapi!(GoogleAppsScriptAPI)めも

apiのreturn書いていく

gasはリダイレクト挟むのでちょっとめんどくさい

Hello World!!

text/plain

return ContentService.createTextOutput("Hello World!!");
Hello World!!

Content-Type : text/plain; charset=utf-8

text/html

return HtmlService.createHtmlOutput('Hello, world!');
<!doctype html>
<html>

<head>
    <meta name="chromevox" content-script="no">
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"
        nonce="ZRWwMEkG0_73RGtk4pYMQw">
    <link rel="stylesheet" href="/static/macros/client/css/1149123825-mae_html_css_ltr.css">
    <script type="text/javascript" src="/static/macros/client/js/4045692911-warden_bin_i18n_warden__ja.js"></script>
</head>

<body>
    <table id="warning-bar-table" class="full_size" cellspacing="0" cellpadding="0">
        <tr>
            <td>
                <div id="warning" class="warning-bar"></div>
            </td>
        </tr>
        <tr>
            <td style="height: 100%"><iframe id="sandboxFrame"
                    allow="accelerometer *; ambient-light-sensor *; autoplay *; camera *; clipboard-read *; clipboard-write *; encrypted-media *; fullscreen *; geolocation *; gyroscope *; magnetometer *; microphone *; midi *; payment *; picture-in-picture *; screen-wake-lock *; speaker *; sync-xhr *; usb *; web-share *; vibrate *; vr *"
                    sandbox="allow-downloads allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation">
                </iframe>
            </td>
        </tr>
    </table>
    <script nonce="3eXeFmkNRXjMk5KKTF1vmQ">
        (function() {
var el = document.getElementById('sandboxFrame');
el.onload = function() {
goog.script.init("\x7b\x22functionNames\x22:\x5b\x22doPost\x22,\x22doGet\x22\x5d,\x22sandboxMode\x22:\x22IFRAME_SANDBOX\x22,\x22callbackTimeout\x22:390000,\x22deploymentId\x22:\x22AKfycbzg24jdPi8XrEqbYuEcEXGw6uNo45CYhHFzkbnBIuv-VnSZkj7I9Cd_7B08mj7ULUPSew\x22,\x22eei\x22:\x22\x22,\x22sandboxHost\x22:\x22https:\/\/n-jjm2ugvc7rl77y64uxvt4zqj3wwutwalp3zfcyy-0lu-script.googleusercontent.com\x22,\x22clientSideProperties\x22:\x7b\x22google.script.sandbox.mode\x22:\x22IFRAME_SANDBOX\x22,\x22google.script.host.origin\x22:\x22https:\/\/docs.google.com\x22\x7d,\x22actionPrefix\x22:\x22\/macros\/s\/AKfycbzg24jdPi8XrEqbYuEcEXGw6uNo45CYhHFzkbnBIuv-VnSZkj7I9Cd_7B08mj7ULUPSew\x22,\x22userHtml\x22:\x22Hello, world!\x22,\x22ncc\x22:\x22\x7b\\\x22awhs\\\x22:true\x7d\x22\x7d", "", undefined, true , false  , "false", "https:\/\/n-jjm2ugvc7rl77y64uxvt4zqj3wwutwalp3zfcyy-0lu-script.googleusercontent.com", "\/\/drive.google.com\/abuse?id\x3dAKkXjozWZSjo3GHnUQ_RU9z968W3RYAacc3dbAKN_VDyAXh89b6BunpQ776hH2UtKiuQCtNQOhrM4OwE1w8m1haE7HEopNB6YI4baW3k%3A0");}
el.src = 'https:\/\/n-jjm2ugvc7rl77y64uxvt4zqj3wwutwalp3zfcyy-0lu-script.googleusercontent.com\/userCodeAppPanel';
}());
    </script>
</body>

</html>

Content-Type : text/html; charset=utf-8

json

いつかね

← Go home