Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • NodeJS Tutorial
  • NodeJS Exercises
  • NodeJS Assert
  • NodeJS Buffer
  • NodeJS Console
  • NodeJS Crypto
  • NodeJS DNS
  • NodeJS File System
  • NodeJS Globals
  • NodeJS HTTP
  • NodeJS HTTP2
  • NodeJS OS
  • NodeJS Path
  • NodeJS Process
  • NodeJS Query String
  • NodeJS Stream
  • NodeJS String Decoder
  • NodeJS Timers
  • NodeJS URL
  • NodeJS Interview Questions
  • NodeJS Questions
  • Web Technology
Open In App
Next Article:
What is the difference between Service Directive and Module in Angular ?
Next article icon

What are the differences between HTTP module and Express.js module ?

Last Updated : 08 Jan, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

HTTP and Express both are used in NodeJS for development. In this article, we'll go through HTTP and express modules separately

HTTP: It is an in-build module which is pre-installed along with NodeJS. It is used to create server and set up connections. Using this connection, data sending and receiving can be done as long as connections use a hypertext transfer protocol.

Example: Creating a server using the HTTP module in NodeJS.

index.js
// Importing http module  var http = require('http');  // Create a server object which listens on port 300 http.createServer(function (req, res) {     // Write a response to the client     res.write('Hello World!');      // End the response     res.end(); }).listen(3000); 

Run the index.js file using the following command.

node index.js

Output:

Express: Express as a whole is known as a framework, not just as a module. It gives you an API, submodules, functions, and methodology and conventions for quickly and easily typing together all the components necessary to put up a modern, functional web server with all the conveniences necessary for that (static asset hosting, templating, handling CSRF, CORS, cookie parsing, POST data handling, and many more functionalities.

Module Installation: You can install the express module using the following command.

npm i express

Example: Creating a server using the express module in NodeJS.

index.js
// Importing express const express = require('express');  // Creating instance of express const app = express();  // Handling GET / Request app.get('/', function (req, res) {     res.send("Hello World!, I am server created by expresss"); })  // Listening to server at port 3000 app.listen(3000, function () {     console.log("server started"); }) 

Run the index.js file using the following command.

node index.js

Output:

Difference between HTTP module and Express.js module:

The main difference between Node's HTTP module and Express.js is that Express adds extra functionality for building web applications.

HTTP

Express

HTTP comes inbuilt along with NodeJS that is, we don't need to install it explicitly. Express is installed explicitly using npm command: npm install express 
HTTP is not a framework as a whole, rather it is just a module.Express is a framework as a whole.
HTTP does not provide function for static hosting, you require to write your own.Express provide express.static function for static asset hosting. Example: app.use(express.static('public'));
HTTP is an independent module.Express is made on top of the HTTP module.
HTTP module provides various tools (functions) to do things for networking like making a server, client, etc.Express along with what HTTP does provide many more functions in order to make development easy.

Next Article
What is the difference between Service Directive and Module in Angular ?

Y

yogeshsherawat77
Improve
Article Tags :
  • Difference Between
  • Web Technologies
  • Node.js
  • Express.js
  • HTTP
  • NodeJS-Questions
  • Web Technologies - Difference Between

Similar Reads

  • What Are The Differences Between npm and npx?
    When working with Node.js, you will frequently encounter two important tools: npm and npx. While both npm and npx are integral to managing JavaScript dependencies, they serve different purposes. The key difference between npm and npx is that npm is a package manager for installing and managing depen
    4 min read
  • What is the difference between Service Directive and Module in Angular ?
    Angular is a Typescript framework used to build dynamic and Single-Page Applications. This has a strong focus on modularity and reusability of code which helps in creating complex and maintainable applications. At the core, Angular has 3 fundamental building blocks, i.e., Service, Directive and Modu
    6 min read
  • What is the difference between export.create and router.post?
    export.create and router.post are used in the context of backend frameworks like Express JS. They both are used for handling HTTP requests and operate at different levels within the framework. In this article we will learn about export.create and router.post and see the key differences between them.
    3 min read
  • What is the Difference Between a Module & a Namespace in JavaScript ?
    The dynamic web's programming language, JavaScript, has changed significantly over time. "Modules" and "Namespaces" are two particularly important architectural elements that have aided in the development of code organization. Modules in JavaScriptModules enable the control and organization of large
    3 min read
  • Difference between PUT and POST HTTP Request in Express and Postman
    Both PUT and POST are request methods used in the HTTP protocol. In this article, we will introduce the HTTP methods such as PUT and POST in detail, and we will also discuss in detail when to use PUT and when to use POST. Table of Content PUT methodPOST MethodDifference between PUT and POST methodCo
    6 min read
  • Difference between app.use() and app.get() in Express.js
    Express.js, a popular web application framework for Node.js, provides a powerful set of methods for routing HTTP requests. Among these methods, app.use() and app.get() are two fundamental functions that serve different purposes. Understanding their differences is essential for building efficient and
    4 min read
  • Difference between res.send() and res.json() in Express.js?
    In this article, we will learn about res.send() & res.json(), along with discussing the significant distinction that differentiates between res.send() & res.json(). Let us first understand what is res.send() and res.json() in Express.js? res.send() - The res.send() function is used for sendi
    3 min read
  • Difference between app-level and route-level middleware in Express
    Middleware functions are functions that have access to the request object ( req ), the response object ( res ), and the next middleware function in the application's request-response cycle. In this article, we will go through app-level and route-level middleware and also see the key differences betw
    3 min read
  • Difference between app.get() and app.post() in Express.js.
    In ExpressJS, app.get() and app.post() are two different methods used to handle HTTP requests but for different purposes. app.get() in ExpressJS:app.get() is used to handle incoming GET requests. GET requests are commonly used for fetching data from the server. For example, when you open a website i
    2 min read
  • Difference Between req.query and req.params in Express
    In Express, req.query and req.params are used to access different types of parameters in a request. 'req.query' retrieves query string parameters from the URL (e.g., '/search?name=GFG' → 'req.query.name' is '"GFG"'), while 'req.params' retrieves route parameters defined in the URL path (e.g., '/user
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences