Skip to content

Instantly share code, notes, and snippets.

@solarsailer
Created September 23, 2011 13:31
Show Gist options
  • Save solarsailer/1237327 to your computer and use it in GitHub Desktop.
Save solarsailer/1237327 to your computer and use it in GitHub Desktop.
A simple server to do client-side scripting
#!/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