![]() |
VOOZH | about |
The following approach covers how to send different HTML files based on the query parameters in Node.js
Approach: The task can be easily fulfilled by receiving the query parameters and map different HTML files with the respective parameters.
Step 1: Create your project folder and install the express module using the following command:
npm install express
Step 2: Create a main.js file in the root directory of your project and write down the following code in it.
Step 3: Create id1.html and id2.html files in the root directory of your project as shown below.
Step 4: Run the server using the following command from the root directory of the project:
node main.js
Output:
Now go to http://localhost:8080/id2, you will see the following output when id2 is passed as a query parameter.
👁 Image