Express is a very popular framework that is used in NodeJs. Express is build upon NodeJs and also it provides a lot of tools that makes node more easy to use by adding more functionalities. Most of the needed functionalities are handled by express which helps the users to only focus on the business logic and to easily setup routes and to render the things on screen in a fast, optimized and a secured manner.
How to install ExpressJS?
Express can be easily installed by the command "npm i express" .
Installation of ExpressJs |
package.json file will be updated once the installation is successful.
How to import ExpressJS?
To import the installed express module we can use the command " require("express") " .
Accessing the imported express module.
express can be accessed as given below using the given commands.
Firstly a constant called app is created.
And then using this give constant app we can run server as well as we can include the middle wares that are needed by the application.
Port that the server should run is 4000 . |
Running the server in port 4000 |
Creating routers using ExpressJS.
Routers can be created using ExpressJs by using the command "express.Router()" .
Comments
Post a Comment