To make things easier for ourselves in the long run, we are going to use a framework for Node.js. Node is pretty bare bones, which means it can do everything, but it probably needs some work. That work is done for us in different frameworks that all work a little differently. Express (https://expressjs.com/) is one of the more popular frameworks (among Hapi.js and Sails.js), so let's go with that. Simply install Express using npm. Please note that we need Express to run the software, so we use --save instead of --save-dev:
npm install express --save
We can now change our file so it uses Express. We do not need to require the http module because Express has that all wrapped for us. Other than that, the code looks pretty much the same. ...