Written by Sümeyye Sever (notes I took while creating web development projects)
Express is a fast, minimal, and flexible web framework for Node.js. It simplifies the process of building web applications and APIs by providing robust features for routing, middleware, and HTTP utility methods.
GET, POST, PUT, and DELETE requests.Create directory
mkdir “Express Server”
cd Express\ Server/
Create index.js file
touch index.js
Initialise NPM
npm init -y
Install the Express package
npm i express
Write server application in index.js
import express from "express"
const app = express();
app.listen(3000, ()=>{
console.log("Server is running on port 3000");
})
Start server
node index.js
After this when you go to the localhost:3000 on your browser you will see a page that says Cannot GET / Why? Because when you go to that page you(browser) making a HTTP GET request to your express server. But in your server there is no method that handle the GET request. So you see an error page. So how we can handle this? With routing. But first what is http request and also what is localhost? Click the links below if you want to learn about these topics also.