Ex No: 9 | WEB SERVER USING NODE.JS |
---|---|
Aim: | To implement a server that reads and sends a HTML page using node.js. |
Procedure | |
Step1: Install Node Package Manager (npm) in the system. | |
Step2: Initialize Node.js using "npm init -y" in the terminal. | |
Step3: Create a file “server.js” to implement the server. | |
Step4: Include "http", "url" and "fs" modules read the html file and send it to the client. | |
Step6: Create a HTML file “index.html" which is read by the "server.js". | |
Step7: Run the code using "node server.js". | |
Source Code | |
server.js
|
|
Result: | Thus node.js server is implemented to read and send "index.html" file to the client. |