app listen in node js
- Import the required modules:
const express = require('express');
- Create an instance of the Express application:
const app = express();
- Define a route handler:
app.get('/', function (req, res) {
res.send('Hello World!');
});
- Make the application listen on a specific port:
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});