Skip to content

Instantly share code, notes, and snippets.

@nambrot
Created January 5, 2012 20:45
Show Gist options
  • Save nambrot/1567200 to your computer and use it in GitHub Desktop.
Save nambrot/1567200 to your computer and use it in GitHub Desktop.
var static = require('node-static');
var file = new(static.Server)('./public', {cache: 1});
require('http').createServer(function (request, response) {
request.addListener('end', function () {
file.serve(request, response, function (e, res) {
if (e && (e.status === 404)) { //still serve the index file
file.serveFile('/index.html', 200, {cache: 84000}, request, response);
}
});
});
}).listen(process.env.PORT || 3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment