write head node js

// Import the HTTP module to create an HTTP server.
const http = require('http');

// Configure HTTP server to respond with "Hello, World!" to all requests.
const server = http.createServer((req, res) => {
  // Set the HTTP header with status code 200 (OK) and content type text/plain.
  res.writeHead(200, {'Content-Type': 'text/plain'});

  // Send the response body as "Hello, World!".
  res.end('Hello, World!\n');
});

// Listen on port 3000, IP address defaults to 127.0.0.1.
server.listen(3000);

// Put a friendly message on the terminal.
console.log('Server running at http://127.0.0.1:3000/');