Skip to content

Instantly share code, notes, and snippets.

@hunnycode
Last active May 11, 2016 05:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hunnycode/a9528de072dd4ef5d4a019f40c1e815e to your computer and use it in GitHub Desktop.
Save hunnycode/a9528de072dd4ef5d4a019f40c1e815e to your computer and use it in GitHub Desktop.
【ハンズオン資料】IBM Bluemix OpenWhisk もくもく会 ref: http://qiita.com/joohounsong/items/ba4657549138b2fc47ba
function main(params) {
return {payload: 'Hello, ' + params.name + ' from ' + params.place};
}
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