'use strict'; const http = require('http'); // ---------------------------------------------------------------------- const hostname = '0.0.0.0'; const port = 3000; // ---------------------------------------------------------------------- var logic = require('./logic.js'); // ---------------------------------------------------------------------- function getPage(req) { var route = req.url.substring(1); var query = logic.riddle_me(route); console.log(`Serving route ${route}`); return ` ${query.question}?

${query.question}?

${query.answer}!

`; } // ---------------------------------------------------------------------- const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/html'); res.write(getPage(req)); res.end(); console.log(`Serviced request ${req}`); }).listen(port, hostname, () => { console.log(`Server running at http://${hostname}:${port}/`); });