Created
September 23, 2011 13:31
-
-
Save solarsailer/1237327 to your computer and use it in GitHub Desktop.
A simple server to do client-side scripting
This file contains 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/bin/env node | |
var express = require('/usr/local/lib/node_modules/express'); | |
var app = express.createServer(); | |
// get the dir from the command line | |
const DIR = process.argv[2] || __dirname; | |
const PORT = process.argv[3] || 4242; | |
// a little bit of configuration... | |
app.configure(function() { | |
app.use(express.methodOverride()); | |
app.use(express.bodyParser()); | |
app.use(app.router); | |
}); | |
app.configure('development', function () { | |
app.use(express.static(DIR)); | |
app.use(express.errorHandler({ | |
dumpExceptions: true, | |
showStack: true | |
})); | |
}); | |
// start the server | |
app.listen(PORT); | |
console.log('Server startup, with basedir "' + DIR + '" on port ' + PORT + '.'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment