Created
September 26, 2016 22:34
-
-
Save alexkafer/176ec799dad60d3206b6c1404b55a389 to your computer and use it in GitHub Desktop.
Simple Google Script service that responds to get requests and outputs the data from a Google Sheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doGet() { | |
var spreadsheet = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/1hN_tx5IVVGJHbEhdKWgBowHwgeVTEQbl9h046ZJNyiE/edit#gid=0'); | |
var sheet = spreadsheet.getSheets()[0]; | |
var values = sheet.getSheetValues(1,1, sheet.getLastRow(), 9); | |
var finalOutput = { | |
fixtures: [] | |
}; | |
for (var y = 0; y < values.length; y++) { | |
var fixture = values[y]; | |
var dmxChannel = fixture[0]; | |
var object = fixture[1]; | |
var location = fixture[7]; | |
var fixture = { | |
name: object, | |
channel: dmxChannel, | |
location: location | |
} | |
finalOutput.fixtures.push(fixture); | |
var stringOutput = "DMX: " + dmxChannel + " Object: " + object + " Location: " + location + "\n"; | |
Logger.log(stringOutput + "\n"); | |
} | |
return ContentService.createTextOutput(JSON.stringify(finalOutput)) | |
.setMimeType(ContentService.MimeType.JSON); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment