Skip to content

Instantly share code, notes, and snippets.

@scothis
Created November 14, 2011 18:50
Show Gist options
  • Save scothis/1364741 to your computer and use it in GitHub Desktop.
Save scothis/1364741 to your computer and use it in GitHub Desktop.
Serve static HTTP requests from any directory
// alias serv="node path/to/serv.js"
var http = require('http'),
express = require('express'),
path = process.env.PWD,
port = process.argv[2] || 8000,
app = express.createServer();
app.configure(function(){
app.use(app.router);
app.use(express.static(path));
app.use(express.directory(path));
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
console.log("Serving files from " + path + " at localhost:" + port);
app.listen(port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment