```js
// http is native to Node.js, so we only need to require it
const http = require('http');
// the http module has a createServer method
// takes one arg: a callback
// the callback has two args: req, res
const server = http.createServer((req, res) => {
// console.log(req);
// res is our way of responding to the requestor
// an http message consists of:
// 1. start-line (node takes care of this)
// 2. header
// 3. body
// writeHead() writes out the headers and takes 2 args:
// 1. status code
// 2. object for the mime-type
res.writeHead(200, {'content-type': 'text/html'});
// to write the body out, we use res.write
res.write('<h1>Hello, World!</h1>');
// to let the browser know that we're ready to close the connection
res.end();
});
// createServer returns an object with a listen() method
// listen() takes one arg: a port to listen to http traffic on
server.listen(3000);
```
#### More info
[[Anatomy of an HTTP Transaction]]
___
**Tags**: #node