Created
November 14, 2011 18:50
-
-
Save scothis/1364741 to your computer and use it in GitHub Desktop.
Serve static HTTP requests from any directory
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
// 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