0% found this document useful (0 votes)
2 views

05_Create_Web_Application_Using_Expressjs_Node_Project_Approach

This document outlines the steps to create a web application using Express.js in a Node.js project on Ubuntu. It includes instructions for creating a directory, setting up a Node project, downloading the Express module, creating an Express server file, and executing the application. The final step involves verifying the application by accessing it through a web browser at a specified URL.

Uploaded by

Hemant Jadhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

05_Create_Web_Application_Using_Expressjs_Node_Project_Approach

This document outlines the steps to create a web application using Express.js in a Node.js project on Ubuntu. It includes instructions for creating a directory, setting up a Node project, downloading the Express module, creating an Express server file, and executing the application. The final step involves verifying the application by accessing it through a web browser at a specified URL.

Uploaded by

Hemant Jadhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Lesson 06 Demo 05

Create Web Application Using Expressjs Node Project Approach

Objective: Create Web Application Using ExpressJs Node Project Approach

Tools required: Ubuntu, Web browser

Prerequisites: None

Steps to be followed:

1. Create a new directory


Prerequisites: None
2. Set up a new node project and download the module
3. Create a new file and save that
4. Execute the created file

Step 1: Create a new directory

1.1 Run the given command to create a new directory

mkdir expressExample
1.2 Go to the newly created directory by running the given command

cd expressExample

Step 2: Set up a new node project and download the module

2.1 Select default options while setting up the node project

npm init -y
2.2 This creates a package.json file in the backend
2.3 Open the package.json file and add the below content

"dependencies": {

"express": "^4.17.1"

2.4 Use the given command to download the modules.

npm install express


Step 3: Create a new file and save it

3.1 Run the below command to create a new file with the name express.js file

nano express.js
3.2 Paste the below content into the file

var express = require('express');

var app = express();

var port = 5000;

app.get('/',function (request, response) {

response.send("Hello World");
})

var server = app.listen(port , function () {

var host = server.address().address


var port = server.address().port
console.log("Sample app ay http://%s:%s", host, port)
});
Note: Press ctrl + X, then click on Y and Enter to save the file.

Step 4: Execute the created file

4.1 Run the newly created file.

node express.js
4.2 Go to the given URL to verify if the app is working

http://localhost:5000

You might also like