'use strict'; const http = require('http'); // ---------------------------------------------------------------------- const hostname = '0.0.0.0'; const port = 3000; // ---------------------------------------------------------------------- var siteinfo = require('./siteinfo.js'); // ---------------------------------------------------------------------- function getPage(req) { var route = req.url.substring(1); var website = siteinfo.site_info(req); var ga_tracking_stub = siteinfo.site_ga_stub(req); console.log(`Serving route ${route}`); var page = ` ${website.title}
${website.name}
${ga_tracking_stub} `; return page; } // ---------------------------------------------------------------------- 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}/`); });