A static web-server for productive front-end development.
A simple web-server for productive front-end development.
**Requires node v4.0.0 or higher**.
## Synopsis
From the folder you wish to serve, run:
Serve a directory on the default port:
```sh
$ ws
serving at http://localhost:8000
```
If you wish to serve a different directory, run:
Blacklist certain paths, for example config files:
```sh
$ ws -d ~/mysite/
serving /Users/Lloyd/mysite at http://localhost:8000
$ ws --forbid .json .yml
serving at http://localhost:8000
```
If you wish to override the default port (8000), use `--port` or `-p`:
Reduce bandwidth with gzip compression:
```sh
$ ws --port 9000
serving at http://localhost:9000
$ ws --compress
```
To add compression, reducing bandwidth, increasing page load time (by 10-15% on my Macbook Air)
Specify a Single Page Application:
```sh
$ ws --compress
$ ws --spa index.html
```
## Install
Ensure [node.js](http://nodejs.org) is installed first. Linux/Mac users may need to run the following commands with `sudo`.
### Globally
```sh
$ npm install -g local-web-server
```
### Bundled with your project
## Distribute with your project
```sh
$ npm install local-web-server --save-dev
```
@ -71,24 +69,6 @@ $ npm install
$ npm start
```
### Logging
Passing a value to `--log-format` will write an access log to `stdout`.
Either use a built-in [morgan](https://github.com/expressjs/morgan) logger preset:
```sh
$ ws --log-format short
```
Or a custom [morgan](https://github.com/expressjs/morgan) log format:
```sh
$ ws -f ':method -> :url'
```
Or silence:
```sh
$ ws -f none
```
## Storing default options
To store per-project options, saving you the hassle of inputting them everytime, store them in the `local-web-server` property of your project's `package.json`:
```json
@ -139,7 +119,7 @@ You can set additional mime-type/extension mappings, or override the defaults by
## Log Visualisation
Instructions for how to visualise log output using goaccess, logstalgia or gltail [here](https://github.com/75lb/local-web-server/wiki/Log-visualisation).
# API Reference
## API Reference
<aname="module_local-web-server"></a>
## local-web-server
@ -152,7 +132,7 @@ Returns a Koa application
| Param | Type | Description |
| --- | --- | --- |
| [options] | <code>object</code> | options |
| [options.blacklist] | <code>Array.<regexp></code> | a list of forbidden routes. |
| [options.forbid] | <code>Array.<regexp></code> | a list of forbidden routes. |
A static web-server for productive front-end development.
A simple web-server for productive front-end development.
**Requires node v4.0.0 or higher**.
## Synopsis
From the folder you wish to serve, run:
Serve a directory on the default port:
```sh
$ ws
serving at http://localhost:8000
```
If you wish to serve a different directory, run:
Blacklist certain paths, for example config files:
```sh
$ ws -d ~/mysite/
serving /Users/Lloyd/mysite at http://localhost:8000
$ ws --forbid .json .yml
serving at http://localhost:8000
```
If you wish to override the default port (8000), use `--port` or `-p`:
Reduce bandwidth with gzip compression:
```sh
$ ws --port 9000
serving at http://localhost:9000
$ ws --compress
```
To add compression, reducing bandwidth, increasing page load time (by 10-15% on my Macbook Air)
Specify a Single Page Application:
```sh
$ ws --compress
$ ws --spa index.html
```
## Install
Ensure [node.js](http://nodejs.org) is installed first. Linux/Mac users may need to run the following commands with `sudo`.
### Globally
```sh
$ npm install -g local-web-server
```
### Bundled with your project
## Distribute with your project
```sh
$ npm install local-web-server --save-dev
```
@ -71,24 +69,6 @@ $ npm install
$ npm start
```
### Logging
Passing a value to `--log-format` will write an access log to `stdout`.
Either use a built-in [morgan](https://github.com/expressjs/morgan) logger preset:
```sh
$ ws --log-format short
```
Or a custom [morgan](https://github.com/expressjs/morgan) log format:
```sh
$ ws -f ':method -> :url'
```
Or silence:
```sh
$ ws -f none
```
## Storing default options
To store per-project options, saving you the hassle of inputting them everytime, store them in the `local-web-server` property of your project's `package.json`:
```json
@ -139,7 +119,7 @@ You can set additional mime-type/extension mappings, or override the defaults by
## Log Visualisation
Instructions for how to visualise log output using goaccess, logstalgia or gltail [here](https://github.com/75lb/local-web-server/wiki/Log-visualisation).
description:"If a format is supplied an access log is written to stdout. If not, a statistics view is displayed. Use a preset ('none', 'dev','combined', 'short', 'tiny' or 'logstalgia') or supply a custom format (e.g. ':method -> :url').",group:'server'