diff --git a/bin/http-server b/bin/http-server index 926e0dd7..7d9bac9d 100755 --- a/bin/http-server +++ b/bin/http-server @@ -18,6 +18,7 @@ if (argv.h || argv.help) { 'usage: http-server [path] [options]', '', 'options:', + ' -b Base path [/]', ' -p Port to use [8080]', ' -a Address to use [0.0.0.0]', ' -d Show directory listings [true]', @@ -94,6 +95,7 @@ else { function listen(port) { var options = { + baseDir: argv.b, root: argv._[0], cache: argv.c, showDir: argv.d, diff --git a/lib/http-server.js b/lib/http-server.js index 7e3e06df..8d40fe17 100644 --- a/lib/http-server.js +++ b/lib/http-server.js @@ -43,6 +43,7 @@ function HttpServer(options) { this.headers = options.headers || {}; + this.baseDir = options.baseDir === undefined ? '/' : options.baseDir; this.cache = options.cache === undefined ? 3600 : options.cache; // in seconds. this.showDir = options.showDir !== 'false'; this.autoIndex = options.autoIndex !== 'false'; @@ -94,6 +95,7 @@ function HttpServer(options) { } before.push(ecstatic({ + baseDir: this.baseDir, root: this.root, cache: this.cache, showDir: this.showDir, diff --git a/package.json b/package.json index f42a2079..ffb6441d 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "dependencies": { "colors": "1.0.3", "corser": "~2.0.0", - "ecstatic": "^2.0.0", + "ecstatic": "^3.0.0", "http-proxy": "^1.8.1", "opener": "~1.4.0", "optimist": "0.6.x",