![]() |
In web application development, Express.js is one of the simplified frameworks for the creation of scalable web servers with proper features for building web and mobile applications. Express.js has list of middleware which makes developers easy to quickly set up servers, define routes, and handle HTTP requests. PrerequisitesIn this article, we will create a simple server using Express.js and also handle the client’s request for testing the created server using Express.js. Steps to create a simple server using Express.jsStep 1: Firstly, we will make the folder named root by using the below command in the VScode Terminal. After creation use the cd command to navigate to the newly created folder. mkdir root Step 2: Once the folder is been created, we will initialize NPM using the below command, this will give us the package.json file. npm init -y Step 3: Once the project is been initialized, we need to install Express dependencies in our project by using the below installation command of NPM. npm i express Dependencies: "dependencies": { Step 4: Now create the below Project Structure in your project which includes public/index.html and server.js file. Step 5: Now, we need to write code for our server.js file and in index.html.
To run the application, we need to start the server by using the below command. node server.js Output: |
Reffered: https://www.geeksforgeeks.org
Express.js |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 15 |