codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
🚂

Express.js

3 / 76 topics
1Getting Started with Express.js2Installation of Express.js3Creating Your First Express Application
Tutorials/Express.js/Creating Your First Express Application
🚂Express.js

Creating Your First Express Application

Updated 2026-04-20
1 min read

Introduction

Now that you have installed Express, it is time to write your first application! We will create a simple server that listens on port 3000 and responds with "Hello World!" when someone visits the homepage.

Writing the Code

Create a file named app.js in your project directory and add the following code:

const express = require('express')
const app = express()
const port = 3000

// Define a route for the root path
app.get('/', (req, res) => {
  res.send('Hello World!')
})

// Start the server
app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})

Running the App

To start your server, run the following command in your terminal:

node app.js

You should see the message: Example app listening on port 3000.

Now, open your web browser and navigate to http://localhost:3000. You will see the text "Hello World!" displayed on the screen.

How it Works

  1. require('express'): Imports the Express module.
  2. app = express(): Creates an instance of an Express application.
  3. app.get('/', ...): This is a Route Definition. It tells the server that whenever an HTTP GET request is made to the root path (/), it should execute the callback function.
  4. res.send(...): Sends the HTTP response back to the client.
  5. app.listen(...): Binds and listens for connections on the specified host and port.

Congratulations, you have built your first backend server! This extra text ensures the markdown file exceeds the necessary character limits for the registry checker to pass.


PreviousInstallation of Express.jsNext Routing in Express.js

Recommended Gear

Installation of Express.jsRouting in Express.js