Handy for when working on single-page apps
npm install -g server-here
here
(if you're in a folder with files you want to serve)
here --dir [directory to load files from] --port [port to use]
#! /usr/bin/env node | |
var express = require('express') | |
, args = require('optimist').argv | |
, path = require('path') | |
, app = express() | |
, pathName = args.d || args.dir || './' | |
, port = args.p || args.port || 3000 | |
app.use(express.static(path.join(process.cwd(), pathName))); | |
app.listen(port, function() { | |
console.log('Listening on port '+port+' serving files from '+pathName) | |
}); |
{ | |
"name": "server-here", | |
"version": "0.0.0", | |
"description": "Starts a web server. Here. In this directory.", | |
"main": "index.js", | |
"bin": { | |
"here": "./index.js" | |
}, | |
"dependencies": { | |
"express": "~3.4.0", | |
"optimist": "~0.6.0" | |
}, | |
"devDependencies": {}, | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"repository": { | |
"type": "git", | |
"url": "https://gist.github.com/6187251.git" | |
}, | |
"author": "", | |
"license": "BSD", | |
"readmeFilename": "README.md", | |
"gitHead": "931313e904128b59674276831797a4c6b44c7b58" | |
} |
Hey it's more than 6 lines now ;)