What is HTTP module in Nodejs?
- How to import HTTP module
- Declare Port
- Creating Server
The http.createServer() method turns your computer into an HTTP server.
The http.createServer() method creates an HTTP Server object.
The HTTP Server object can listen to ports on your computer and execute a function, a requestListener, each time a request is made.
- listen server
Syntax
- server.listen(port, hostname, backlog, callback);
Parameter | Description |
---|---|
port | Optional. Specifies the port we want to listen to |
hostname | Optional. Specifies the IP address we want to listen to |
backlog | Optional. Specifies the max length of the queue of pending connections. Default 511 |
callback | Optional. Specifies a function to be executed when the listener has been added |
- Read HTML file and send Responsive to Server
- Send Many HTML file (first check url.req then using this send html file)
- Sending CSS Javascript Html and all file on server (mini site )