Skip to content

Instantly share code, notes, and snippets.

@muddydixon
Created May 31, 2012 05:03
Show Gist options
  • Save muddydixon/2841160 to your computer and use it in GitHub Desktop.
Save muddydixon/2841160 to your computer and use it in GitHub Desktop.
node server connect >= 1.8.3
var fs = require('fs')
, path = require('path')
if(process.argv[2] === '--help' || process.argv[2] === '-h'){
console.log('USAGE: node ./server.js <public dir: default public> <port: default 3010>');
process.exit(0);
}
var public = process.argv[2]
, port = process.argv[3];
if(port === undefined){
public = port;
port = 3010;
}
if(public === undefined){
public = 'public';
}
if(!path.existsSync(public)){
console.log('USAGE: node ./server.js <public dir: default public> <port: default 3010>');
process.exit(-1);
}
var connect = require("connect")
, app = connect()
.use(connect.static(public))
.use(function(req, res){
res.end("");
})
.listen(port);
console.log('WebServer Start in public = ' + public + ', listen port = ' + port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment