Files
2026-03-23 13:16:53 +05:30

1.1 KiB

Express.js Basics

Introduction

This project explains the basics of Express.js. Express.js is a web framework built on Node.js that simplifies backend development.

Express.js is used to create web servers and APIs easily. It provides simple methods for routing and handling HTTP requests.


Features of Express.js

  • Simple and easy routing
  • Middleware support
  • Fast server creation
  • API development

Example: Simple Express Server

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

app.get('/', (req, res) => {
  res.send('Hello from Express!');
});

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

Routing Example

app.get('/about', (req, res) => {
  res.send('This is About Page');
});

Middleware Example

app.use((req, res, next) => {
  console.log('Request received');
  next();
});

How to Run

  1. Install Node.js
  2. Install Express:
npm init -y
npm install express
  1. Create a file app.js
  2. Run:
node app.js
  1. Open browser:
http://localhost:3000

Technologies Used

  • Node.js
  • Express.js
  • JavaScript