Skip to content

Instantly share code, notes, and snippets.

@vunb
Forked from 8bitDesigner/README.md
Last active August 29, 2015 14:08
Show Gist options
  • Save vunb/8ee34d34cf53b7c7ad64 to your computer and use it in GitHub Desktop.
Save vunb/8ee34d34cf53b7c7ad64 to your computer and use it in GitHub Desktop.

Simple Static file server

Handy for when working on single-page apps

Usage

  1. npm install -g server-here
  2. here (if you're in a folder with files you want to serve)

Options

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"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment