return ContentService.createTextOutput(字串);
```
2. HTML: ```
return HtmlService.createHtmlOutput(HTML);
```
3. JSON: ```
var JSONString = JSON.stringify(result);
return ContentService.createTextOutput(JSONString)
.setMimeType(ContentService.MimeType.JSON);
```
四、路由
```
//2. Route
var Route = {};
Route.path = function(route, callback){
Route[route] = callback;
}
function doGet(e) {
Route.path("form", form);
if(Route[e.parameter.op]){
return Route[e.parameter.op](e);
} else {
return index(e);
}
}
```
```
//1. Run > setup
var SCRIPT_PROP = PropertiesService.getScriptProperties(); // new property service
//2. Route
var Route = {};
Route.path = function(route, callback){
Route[route] = callback;
}
function doGet(e) {
//Route.path("form", form);
if(Route[e.parameter.op]){
return Route[e.parameter.op](e);
} else {
return index(e);
}
}
//將試算表id 寫入屬性
function setup() {
//必須由試算表建立指令碼編輯器
var ss = SpreadsheetApp.getActiveSpreadsheet();
//設定試算表 id
SCRIPT_PROP.setProperty("id", ss.getId());
//管理員email
SCRIPT_PROP.setProperty("adminEmail", Session.getActiveUser().getEmail());
//取得全域變數(試算表有異動,請執行 setup())
var ws = ss.getSheetByName("全域變數");
//取得「全域變數」陣列
var global = ws.getSheetValues(2,1,ws.getLastRow()-1,ws.getLastColumn());
var colName = global.map(function(r){ return r[1] });//欄位名稱
var colValue = global.map(function(r){ return r[3] });//值
for(i in colName){
SCRIPT_PROP.setProperty(colName[i], colValue[i]);
}
}
```