The http.createServer() method includes request and response parameters which is supplied by Node.js. Now, let's see how to handle HTTP request and send response in Node.js web server. This is how you create a Node.js web server using simple steps. Node.js web server at port 5000 is running. Run the above web server by writing node server.js command in command prompt or terminal window and it will display message as shown below. Finally, call listen() method of server object which was returned from createServer() method with port number, to start listening to incoming requests on port 5000. The next step is to call createServer() method of http and specify callback function with request and response parameter. The http module is a core module of Node.js, so no need to install it using NPM. In the above example, we import the http module using require() function.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |