How to create an Http Server using Node.js?



How to create an Http Server using Node.js?..

Answer / Mamata Kumari

To create an HTTP server using Node.js without any additional packages, follow these steps:
1. Import the http module.
2. Create a new instance of the http.Server object.
3. Define a request listener function that will handle incoming requests.
4. Pass the request listener function and a port number to the http.Server constructor.
5. Call the listen() method on the created server instance.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Node.js Interview Questions

What is libuv?

1 Answers  


How to create a simple chat app using socket.io in node.js?

1 Answers  


Is node js worth learning?

1 Answers  


Do you know what mean stack means?

1 Answers  


What are global installations of dependencies?

1 Answers  


How can we control versioning about packages in node.js?

1 Answers  


What is the package.json and name of attributes?

1 Answers  


What is repl? What purpose it is used for?

1 Answers  


Which command is used to import external libraries in node.js?

1 Answers  


How "control flow" controls the functions calls?

1 Answers  


List out some new features introduced in es6?

1 Answers  


What is template engine?

1 Answers  


Categories