Skip to content

Instantly share code, notes, and snippets.

@Arood
Created November 21, 2013 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arood/7579368 to your computer and use it in GitHub Desktop.
Save Arood/7579368 to your computer and use it in GitHub Desktop.
Quick web server for static files
var fs = require('fs'),
http = require('http');
http.createServer(function (req, res) {
fs.readFile(__dirname + "/." + req.url.split("?")[0], function (err,data) {
if (err) {
res.writeHead(404);
res.end(JSON.stringify(err));
return;
}
res.writeHead(200);
res.end(data);
});
}).listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment