Skip to content

Latest commit

 

History

History
21 lines (16 loc) · 503 Bytes

section1.1.md

File metadata and controls

21 lines (16 loc) · 503 Bytes

Section 1.1: Hello World HTTP server

let http = require('http');

http.createServer((req, res) => {
  // 1. Tell the browser everything is OK (Status code 200), and the data is in plain text
  res.writeHead(200, {
    'Content-Type': 'text/plain'
  });
  // 2. Write the announced text to the body of the page
  res.write('Hi Morol\n');

  // 3. Tell the server that all of the response headers and body have been sent
  res.end();

}).listen(3030);