How to Set up an Express Server :
Step 1: Installing Node Js First, check if the node and npm are installed in your system. if not installed Please refer to this article: Installation of Node JS on Windows
Step 2: Initialize NPM: Create and Locate your project folder in the terminal & type the command
npm init -y // It initializes our node application & creates a package.json file.
Step 3: Installing express package in project. Go to the Project directory and install express
npm i express
Step 4: Creating a Server
- Create the server.js file that include the implementation of server creation
- Paste the below code in server.js or you can refer this website
const express = require("express");
const app = express();
const PORT = 3000;
app.listen(PORT, (req, res) => {
console.log("App Started on App:" + PORT);
});
Create an Express server with EJS Templating Engine
EJS (Embedded JavaScript) is a simple and popular templating engine for JavaScript. it is designed to generate HTML markup with plain JavaScript.
EJS is commonly used in server-side web applications built with Node.js. It allows you to generate dynamic HTML pages. In this article, we will create student data that includes fields like name, email, and enrolled course & display that table using EJS.