Node.js: get path from the request
var http = require(‘http’); var url = require(‘url’); var fs = require(‘fs’); var neededstats = []; http.createServer(function(req, res) { if (req.url == ‘/index.html’ || req.url == “https://stackoverflow.com/”) { fs.readFile(‘./index.html’, function(err, data) { res.end(data); }); } else { var p = __dirname + “https://stackoverflow.com/” + req.params.filepath; fs.stat(p, function(err, stats) { if (err) { throw err; } … Read more