Thursday, November 19, 2020

create your custom server using nodejs

 In nodejs we donot need any 3rd party software to create a server.

1. HTTP module is required to create a server. So first we will include this.

2. Create a  object for server by using the HTTP  createServer method. 

3. Pass req, res as the parameters of this obj.  

NOTE: Use the ES6 arrow function to reduce the function length

4. Send a response('hello from the server side.') from the server-side.

5. Make the sever listen at a port say 3000.

6. On the sever, show that the server is listening. 

NOTE: use nodemon to check if the server has been created

Labels: ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home