Node Js - Create a Node Server using Express

Node Js - Create a Node Server using Express

Express is a minimal, high performance and flexible Node.js web application framework that provides a robust set of features to develop web and mobile applications.

Features

  • Express provides robust routing to handle various HTTP methods and URLs in Node.
  • It focuses on high performance
  • Super-high test coverage
  • HTTP helpers (redirection, caching, etc)
  • View system supporting 14+ template engines
  • Executable for generating applications quickly


Now, we will create a node server using express

Install express npm package

npm install express 



now, in the browser:



Code for your reference:

const express = require("express");
const expressServer = express();

expressServer.get("", (req, res) => {
res.send('Hello Express...')

});

expressServer.listen(8000, ()=>{
 console.log('Node is up and running on 8000')
})


Steps to create a Node server using Express

1. Install the express npm package
2. Import the package into your js file using require.
3. Write a handler for handling the requests to your node server.

4. Mention the port number at which your server will be running and handling the client requests using the listen() method.


Post a Comment

0 Comments