The Buffer constructor is highly powerful, but with potential for danger.
Let's simply create an index.js file with the following code:
const http = require('http')const server = http.createServer((req, res) => { if (req.method === 'GET') { res.setHeader('Content-Type', 'text/html') if (req.url === '/') return res.end(html()) res.setHeader('Content-Type', 'application/json') if (req.url === '/friends') return res.end(friends()) return } if (req.method === 'POST') { if (req.url === '/') return action(req, res) }})function html (res) { return ` <div id=friends></div> <form> <input id=friend> <input type=submit value="Add Friend"> </form> <script> void function () { var friend = document.getElementById('friend') var friends = ...