Nowadays, we take a lot of photos, it’s always hard to classify them, what if we use the latest advances in machine learning to classify them automatically with a tag system?

Throughout this series of 4 episodes we will code a NodeJs API which, on image upload assigns it differents tags, and we can request the photos with a certain tag to the API.


This tutorial requires a basic knowledge of javascript and the latest features of Javascript: ES6, if the term is not familiar to you I invite you to look at You must also have a basic knowledge of the command line, because we will use the terminal in some cases.

Part 1: The Node.js Server

First of all, if you have not installed Node.js on your computer , you will have to go here to install it , Node.js comes with its dependency manager npm

Node.js is a command-line interpreter for running javascript server-side code.
The http module, already integrated, allows to receive, process and respond to http requests.
We create our server, we  “require”  the module http and we made the server listen on port 3000:

// content of index.js
const http = require('http')
const port = 3000
const requestHandler = (request, response) => {
response.end('Hello Node.js Server!')

const server = http.createServer(requestHandler)

// bind the server on port
server.listen(port, (err) => {
if (err) {
return console.log('something bad happened', err)

console.log(`server is listening on ${port}`)

And we start it with the following command:

$ node index.js

Now with your browser you can go to the following address: http: // localhost: 3000, you should see “Hello World ”


The “requestHandler” is going to be invoked each time that you will access the above url

The listen method on the previously instantiated server object will ask the server to listen the http port (3000 in our case), if there is an error (eg. port 3000 is already in use) Error message will appear in the console.

The module http is of low level, so it is necessary to facilitate the creation of our application to use a framework, see a non-exhaustive list of some:

express.js (this is the one we will use)

Finally ,we will initialize npm to handle dependencies for the next tutorial part:

$ npm init -y

The above command will create a file named “package.json” at the root of your project in order to list his dependencies.
In the next part: Express, routing and file upload.