Skip to content

Instantly share code, notes, and snippets.

@seb-patron
Last active December 4, 2016 23:42
Show Gist options
  • Save seb-patron/8b7034c3a16245ab7b64c9df62bd52e0 to your computer and use it in GitHub Desktop.
Save seb-patron/8b7034c3a16245ab7b64c9df62bd52e0 to your computer and use it in GitHub Desktop.
Serves a static file from a server. Requires the node-static module. Used in my Selfie App tutorial.
var static = require('node-static');
// https://www.npmjs.com/package/node-static
// Create a node-static server instance to serve the './public' folder
//
var file = new static.Server('./public');
require('http').createServer(function (request, response) {
request.addListener('end', function () {
file.serve(request, response);
}).resume();
}).listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment