Created
February 9, 2015 13:45
-
-
Save tankcdr/62ef95f09ae16ad3e3c6 to your computer and use it in GitHub Desktop.
watson-developer-cloud and restify question answer service example that runs on Bluemix
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
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) | |
}) |
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
cf create-service question_and_answer question_and_answer_free_plan cmmqa |
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
curl -H "Content-Type: application/json" -X POST http://wdctravel.mybluemix.net/travel/ask \ | |
-d '{"question": "Do I need a visa to enter Italy?"}' |
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
applications: | |
- services: | |
-cmmqa | |
name: wdctravel | |
path: . | |
memory: 128M |
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
cf push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment