Explain routing with a simple example in node js.

Here, we will write a program to route our page using node js. This requires one single file called app.js in the root directory.

app.js

const express = require('express');
const app = express();

app.get('/', routingExample);

app.listen(3000, () => {
  console.log('Server listening on port 3000');
});

function routingExample(req, res) {
    res.send('Welcome to my homepage!');
  }