Last active
October 11, 2015 17:57
-
-
Save sordina/3897222 to your computer and use it in GitHub Desktop.
Little Node Static Server
This file contains hidden or 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 | |
// npm install connect | |
var port = process.argv[2]; | |
var cwd = process.cwd(); | |
if(! port) { | |
throw("Usage: serve <port>"); | |
} | |
console.log("port " + port); | |
console.log("dir " + cwd); | |
var connect = require('connect'); | |
var app = connect() | |
.use(connect.logger('dev')) | |
.use(connect.static(cwd)) | |
console.log('Serving http://localhost:' + port + '/') | |
connect.createServer( app ).listen(port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment