After thorough researching, I decided to use Bluemix for classifying and recognizing images.
I'm have a starter question on how to begin programming using node.js runtime.
I tried to follow this tutorial. However, that is just snippets of code. How do you run them and see it working in the Bluemix environment?
My progress:
-I started the node.js starter application in Bluemix.
-I added the following code and the app.js looks like this:
/*eslint-env node*/
//--------------------------------------------------------------------------
// node.js starter application for Bluemix
//--------------------------------------------------------------------------
// This application uses express as its web server
// for more info, see: http://expressjs.com
var express = require('express');
// cfenv provides access to your Cloud Foundry environment
// for more info, see: https://www.npmjs.com/package/cfenv
var cfenv = require('cfenv');
// create a new express server
var app = express();
// serve the files out of ./public as our main files
app.use(express.static(__dirname + '/public'));
// get the app environment from Cloud Foundry
var appEnv = cfenv.getAppEnv();
// start server on the specified port and binding host
app.listen(appEnv.port, '0.0.0.0', function() {
// print a message when the server starts listening
console.log("server starting on " + appEnv.url);
});
var watson = require('watson-developer-cloud');
var fs = require('fs');
/*var visual_recognition = watson.visual_recognition({
username: '<username>',
password: '<password>',
version: 'v2-beta',
version_date: '2015-12-02'
});*/
var visualRecognition = watson.visual_recognition({
version: 'v3',
api_key: process.env.API_KEY || 'my api key',
version_date: '2015-05-19'
});
var params = {
images_file: fs.createReadStream('./resources/car.png')
};
visualRecognition.classify(params, function(err, res) {
if (err)
console.log(err);
else
console.log(JSON.stringify(res, null, 2));
});
I'm trying to run the code in the Bluemix environment (live edit mode) and not locally. When I hit run the code, the deployment stops and I can't even locate what line of code is making this happen. When I visit the webpage I get the following error:
404 Not Found: Requested route ('myvisualapp.mybluemix.net') does not exist.
I don't understand what's wrong and how to debug the code.
Author level: beginner