Skip to content

Instantly share code, notes, and snippets.

@bmaeser
Created September 21, 2011 17:03
Show Gist options
  • Save bmaeser/1232662 to your computer and use it in GitHub Desktop.
Save bmaeser/1232662 to your computer and use it in GitHub Desktop.
quick serve some static files with node.js
node >= 0.4.1
node-static >= 0.5.9
put somewhere in your $PATH and:
webserver /path/to/dir
# will serve files from that dir
webserver .
# will serve from current dir
#!/usr/bin/env node
var static = require('node-static');
var filedir = process.argv[2]
var fileserver = new static.Server(filedir);
require('http').createServer(function (request, response) {
request.addListener('end', function () {
fileserver.serve(request, response);
});
}).listen(8080);
console.log('Serving static data on port 8080 from dir ' + filedir )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment