sfoster / serverhere

Starts a simple node and express-based static file server in the current directory

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

serverHere

A simple node-based static file server, for quickly standing up an HTTP server to browse from your current directory.

Install

$ git clone https://github.com/sfoster/serverhere.git
$ cd serverhere
$ npm install

Usage

$ node ./index.js

I suggest adding the following to your /.profile or /.login or wherever your shell normally looks when you login.

alias serverhere="node ~/path/to/this/repo/serverHere/index.js $@"

..then you just need

$ serverhere
serving on localhost:3000; out of % /Users/sfoster/dev/somesuch

Now you can point your browser (or curl or whatever) at http://localhost:3000/ and get a directory listing of /Users/sfoster/dev/somesuch. Common file types should be served with the right mime-types, so for quickly testing some HTML/ajax stuff you should be good to go.

Options

There's just a few simple options. serverHere uses the optimist node module which is pretty flexible. I suggest using the format --optionname value.

docRoot

The path to the directory to treat as the document root for the server (defaults to your current working directory.)

$ node ./index.js --docRoot /some/other/directory

port

The port number to listen on (defaults to 3000)

$ node ./index.js --port 8888

hostname

The hostname to listen for requests on (defaults to localhost)

$ node ./index.js --hostname project1.local

logger

The logging style, defaults to 'short'. Passes straight through to connect's logger middleware

Any of the options can be combined:

$ node ./index.js --docRoot /some/other/directory --port 8080 --logging tiny

About

Starts a simple node and express-based static file server in the current directory


Languages

Language:JavaScript 62.0%Language:CSS 20.4%Language:HTML 17.7%