Created
March 3, 2017 06:33
-
-
Save ayoayco/06d45c2c68b05587b4008f244494543d to your computer and use it in GitHub Desktop.
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
//requires node modules: "connect" and "serve-static" | |
var connect = require('connect'); | |
var serveStatic = require('serve-static'); | |
function printUsageAndExit() { | |
console.log("Usage:"); | |
console.log("node webserver.js <port> \"<path>\""); | |
console.log("Examples:"); | |
console.log("node webserver.js 8080 \"../\""); | |
console.log("node webserver.js 80 \"C:/Web/MyApplication\""); | |
process.exit(); | |
} | |
var args = process.argv; | |
if (args.length != 4) { | |
printUsageAndExit(); | |
} | |
var port = args[2]; | |
var path = args[3]; | |
console.log('Starting web server at localhost:' + port + " for directory \"" + path + "\""); | |
connect().use(serveStatic(path)).listen(port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment