Created
May 31, 2012 05:03
-
-
Save muddydixon/2841160 to your computer and use it in GitHub Desktop.
node server connect >= 1.8.3
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
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