Created
February 12, 2011 01:47
-
-
Save dstnbrkr/823394 to your computer and use it in GitHub Desktop.
Launch a webserver anywhere, the current working directory will be the document root
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
#!/usr/local/bin/node | |
var | |
sys = require('sys'), | |
path = require('path'), | |
http = require('http'), | |
paperboy = require('/usr/local/lib/node/paperboy'), | |
PORT = 8003, | |
WEBROOT = process.cwd(); | |
http.createServer(function(req, res) { | |
paperboy | |
.deliver(WEBROOT, req, res) | |
.before(function() { | |
sys.puts('About to deliver: '+req.url); | |
}) | |
.after(function() { | |
sys.puts('Delivered: '+req.url); | |
}) | |
.error(function() { | |
sys.puts('Error delivering: '+req.url); | |
}) | |
.otherwise(function() { | |
res.sendHeader(404, {'Content-Type': 'text/plain'}); | |
res.write('404, Not Found'); | |
res.finish(); | |
}); | |
}).listen(PORT); | |
console.log("Running at http://127.0.0.1:" + PORT); | |
console.log("Document Root: " + WEBROOT); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment