Last active
May 11, 2016 05:12
-
-
Save hunnycode/a9528de072dd4ef5d4a019f40c1e815e to your computer and use it in GitHub Desktop.
【ハンズオン資料】IBM Bluemix OpenWhisk もくもく会 ref: http://qiita.com/joohounsong/items/ba4657549138b2fc47ba
This file contains 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 main(params) { | |
return {payload: 'Hello, ' + params.name + ' from ' + params.place}; | |
} |
This file contains 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
var request = require('request'); | |
function main(msg) { | |
var location = msg.location || 'Vermont'; | |
var url = 'https://query.yahooapis.com/v1/public/yql?q=select item.condition from weather.forecast where woeid in (select woeid from geo.places(1) where text="' + location + '")&format=json'; | |
request.get(url, function(error, response, body) { | |
var condition = JSON.parse(body).query.results.channel.item.condition; | |
var text = condition.text; | |
var temperature = condition.temp; | |
var output = 'It is ' + temperature + ' degrees in ' + location + ' and ' + text; | |
whisk.done({msg: output}); | |
}); | |
return whisk.async(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment