Many times I need just to run a simple webserver in a specific directory. That is the solution I came up with.
Put the files somewhere and then:
$ npm install$ node server.js [<PATH TO DIR> [<PORT>]]| { | |
| "name": "quick-static-server", | |
| "description": "Quick webserver for serving static files in any dir", | |
| "version": "0.0.1", | |
| "author": "korya <[email protected]>", | |
| "dependencies": { | |
| "express": "3.x" | |
| }, | |
| "engines": { | |
| "node": ">=0.10" | |
| } | |
| } | 
| var express = require('express'), | |
| app = express() | |
| var dir = process.argv[2] || __dirname + '/static' | |
| var port = process.argv[3] || process.env.SERVER_PORT || 8080 | |
| app.use(express.static(dir)) | |
| app.use(express.directory(dir)) | |
| app.listen(port) | |
| console.log('Listening on', port) |