Week 12th at Jadu

Ubaidullah Rao
4 min readMay 3, 2021

--

Hi Guys I hope you are doing great !!!

Please stay home stay Safe !!

as you know I was tell all of you my previous blog about React.js and Node.js so now it’s time to know about what is Express.js ???

In this blog I’ll tell all of you what is Express.JS ??

Express.js is a free and open-source web application framework for Node.js. It is used for designing and building web applications quickly and easily. Web applications are web apps that you can run on a web browser. Since Express.js only requires JavaScript, it becomes easier for programmers and developers to build web applications and API without any effort.

Express.js is a framework of Node.js which means that most of the code is already written for programmers to work with. You can build a single page, multi-page, or hybrid web applications using Express.js. Express.js is lightweight and helps to organize web applications on the server-side into a more organized MVC architecture.

what mean Lightweight and MVC in web application??I think these both words are completely new for all of you don’t worry I’ll tell about these word my next blog now here you focused on Express.js !!!

It is important to learn JavaScript and HTML to be able to use Express.js. Express.js makes it easier to manage web applications. It is a part of a JavaScript based technology called MEAN software stack which stands for MongoDB, ExpressJS, AngularJS, and Node.js. Express.js is the backend part of MEAN and manages routing, sessions, HTTP requests, error handling, etc.

The JavaScript library of Express.js helps the programmers to build efficient and fast web apps. Express.js enhances the functionality of the node.js. In fact, if you don’t use Express.js, then you have to do a lot of complex programming to build an efficient API. It has made programming in node.js effortless and has given many additional features.

Why should you use Express.js?

Express.js supports JavaScript which is a widely used language that is very easy to learn and is also supported everywhere. Therefore, if you already know JavaScript, then it will be really easy for you to do programming using Express.js.

With the help of Express.js, you can easily build different kinds of web applications in a short period of time. Express.js provides a simple routing for requests made by clients. It also provides a middleware that is responsible for making decisions to give the correct responses for the requests made by the client

Without Express.js, you have to write your own code to build a routing component which is a time consuming and tedious task. Express.js offers simplicity, flexibility, efficiency, minimalism, and scalability to the programmers. It also has the advantage of powerful performance as it is a framework of Node.js.

Prerequisites: Basic computer literacy. A general understanding of server-side website programming, and in particular the mechanics of client-server interactions in websites.

Objective: To gain familiarity with what Express is and how it fits in with Node, what functionality it provides, and the main building blocks of an Express application.

How to install Express.js??

Firstly, install the Express framework globally using NPM so that it can be used to create a web application using node terminal.

$ npm install express --save

Hello world Example:

Following is a very basic Express app which starts a server and listens on port 3000 for connection. This app responds with Hello World! for requests to the homepage. For every other path, it will respond with a 404 Not Found.

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

app.get('/', function (req, res) {
res.send('Hello World');
})

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

console.log("Example app listening at http://%s:%s", host, port)
})

Save the above code in a file named server.js and run it with the following command.

$ node server.js

You will see the following output −

Example app listening at http://localhost:3000

Open http://localhost:3000 in any browser to see the following result.

Output

  • You can clearly see that we if browse to the URL of localhost on port 3000, you will see the string ‘Hello World’ displayed on the page.
  • Because in our code we have mentioned specifically for the server to listen on port no 3000, we are able to view the output when browsing to this URL

Code Explanation:

That’s awesome so here guys I hope you have understand basic concept of Express.js and you have enjoy to know about Express.js for further learnt

and practice you can go here

Express.js

Tutorial Point

Features of Express.js

1. Faster Server side development
Express.js provides many commonly used features of Node.js in the form of functions that can be readily used anywhere in the program. This removes the need to code for several hours and thus saves time.

2. Middleware
Middleware is a part of the program that has access to the database, client request, and the other middleware's. It is mainly responsible for the systematic organization of different functions of Express.js.

3. Routing
Express.JS provides a highly advanced routing mechanism which helps to preserve the state of the webpage with the help of their URLs.

4. Templating
Express.JS provides templating engines that allow the developers to build dynamic content on the web pages by building HTML templates on the server-side.

5. Debugging
Debugging is crucial for the successful development of web applications. Express.JS makes debugging easier by providing a debugging mechanism that has the ability to pinpoint the exact part of the web application which has bugs.

Stay Connected with me for new Blogs on technical topics !!!

--

--

Ubaidullah Rao

Full Stack Web Developer Tech Enthusiast | Speaker| Writer| DSC Lead | Community Builder| AWS Enthusiast |Find me @ubaidullahrao2