Skip to content

Instantly share code, notes, and snippets.

@tankcdr
Created February 9, 2015 14:46
Show Gist options
  • Save tankcdr/4c4c4bd94ab6b27870bd to your computer and use it in GitHub Desktop.
Save tankcdr/4c4c4bd94ab6b27870bd to your computer and use it in GitHub Desktop.
'use strict'
var wdc = require('watson-developer-cloud-alpha'),
restify = require('restify'),
server = restify.createServer(),
question_and_answer_travel = wdc.question_and_answer({
version: 'v1',
use_vcap_services: true,
dataset: 'travel'
})
server.use(restify.fullResponse())
.use(restify.bodyParser())
server.post('/travel/ask', function(req,res,next) {
var options = {
text: req.params.question
}
question_and_answer_travel.ask(options, function (err, response) {
if (err)
res.send(500,err)
else
res.send(200,response)
return res.next();
})
})
server.listen(process.env.VCAP_APP_PORT,function() {
console.log('Travel service listening on '+server.url)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment