Created
November 21, 2013 10:30
-
-
Save Arood/7579368 to your computer and use it in GitHub Desktop.
Quick web server for static files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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