servedir
Creates a simple web server for a directory
Last updated 3 years ago by remy .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install servedir 
SYNC missed versions from official npm registry.

servedir

servedir is a simple Node web server for offline development and testing: running servedir from a directory will create a quick local web server. servedir is useful for developing scripts that require a standard web environment and can't use the file:// protocol.

The annotated source code is included in the docs/ folder.

Installation

Check out a working copy of the source code with Git, or install servedir via npm. The latter will also install servedir into the system's bin path.

$ git clone git://github.com/remy/servedir.git
$ npm install servedir -g

Usage

servedir [path] [port]

  • path - The location to serve files and directories from. Defaults to the current working directory.
  • port - The port number. Default to 8000.

If no port is given, it'll try to find the next free port from 8000 upwards.

Mocked router

To create a mock router, create a routes.json file in the current working directory, and servedir will respond with your data.

For example:

{
  "GET /foo/:id": {
    "id": "{{id}}",
    "title": "Awesome stuff"
  },
  "POST /ok": {
    "success": true
  },
  "POST /fail": {
    "success": true
  }
}

Now requests to those URLs will respond with JSON for the mocked endpoints.

Example

$ servedir
$ servedir 8001
$ servedir ~/Documents/example
$ servedir ~/Documents/example 8001

Contributors

Current Tags

  • 1.0.1                                ...           latest (3 years ago)

13 Versions

  • 1.0.1                                ...           3 years ago
  • 1.0.0 [deprecated]           ...           6 years ago
  • 0.2.2                                ...           8 years ago
  • 0.2.1                                ...           8 years ago
  • 0.2.0                                ...           8 years ago
  • 0.1.10                                ...           10 years ago
  • 0.1.9                                ...           10 years ago
  • 0.1.5                                ...           10 years ago
  • 0.1.4                                ...           10 years ago
  • 0.1.3                                ...           10 years ago
  • 0.1.2                                ...           10 years ago
  • 0.0.2                                ...           10 years ago
  • 0.0.1                                ...           10 years ago
Maintainers (2)
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 4
Dependencies (1)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |