Node.js HTTP Module

Node.js HTTP Module

Node.js HTTP Module is built-in module which is used to transfer data over the Hyper Text Transfer Protocol (HTTP).

A require() function is used to include the HTTP module in applicaton.

The HTTP module can create an HTTP server that listens to server ports and gives a response back to the client.

A createServer() method of http module is used to create an HTTP server:

Example : 

const http = require('http');

const port = 5555;

const server = http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.end('Welcome to aryatechno tutorials!');

server.listen(port function() {

    console.log(`Server running at port ${port}:${port}`)




Leave a Reply

Your email address will not be published. Required fields are marked *