# glance

> disposable fileserver

Latest version **3.0.9** (published 2023-02-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install glance
pnpm add glance
yarn add glance
bun add glance
```

Provides the command `glance`.

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.9 |
| Published | 2023-02-02 |
| First published | 2013-06-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 22.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 29 |
| Author | jesse keane |
| Maintainers | jarofghosts |
| Keywords | file, server, utility, util, fileserver |

## Links

- npm: https://www.npmjs.com/package/glance
- Repository: https://github.com/jarofghosts/glance
- Homepage: https://github.com/jarofghosts/glance#readme
- Issues: https://github.com/jarofghosts/glance/issues
- npm.io page: https://npm.io/package/glance

## Dependencies (8)

- [mime](https://npm.io/package/mime.md) 1.4.1
- [nopt](https://npm.io/package/nopt.md) 3.0.4
- [filed](https://npm.io/package/filed.md) 0.1.0
- [xtend](https://npm.io/package/xtend.md) 4.0.0
- [html-ls](https://npm.io/package/html-ls.md) 2.1.0
- [bash-color](https://npm.io/package/bash-color.md) 0.0.3
- [stream-replace](https://npm.io/package/stream-replace.md) 1.0.0
- [utils-fs-exists](https://npm.io/package/utils-fs-exists.md) 1.0.1

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 3.0.9 (latest) — 2023-02-02
- 3.0.8 — 2020-07-18
- 3.0.7 — 2019-02-17
- 3.0.6 — 2019-02-17
- 3.0.5 — 2018-02-10
- 3.0.4 — 2018-02-01
- 3.0.3 — 2015-09-26
- 3.0.2 — 2015-03-05
- 3.0.1 — 2014-10-31
- 3.0.0 — 2014-08-03
- 2.0.0 — 2014-07-06
- 1.0.0 — 2014-05-02
- 0.4.1 — 2014-04-29
- 0.4.0 — 2014-04-29
- 0.3.0 — 2014-02-23
- … 24 more at https://npm.io/package/glance/versions

## README

# glance

[![Build Status](https://img.shields.io/travis/jarofghosts/glance.svg?style=flat-square)](https://travis-ci.org/jarofghosts/glance)
[![npm install](https://img.shields.io/npm/dm/glance.svg?style=flat-square)](https://www.npmjs.org/package/glance)
[![npm version](https://img.shields.io/npm/v/glance.svg?style=flat-square)](https://www.npmjs.org/package/glance)
[![License](https://img.shields.io/npm/l/glance.svg?style=flat-square)](https://github.com/jarofghosts/glance/blob/master/LICENSE)

a quick disposable http server for static files

## installation

```bash
npm install -g glance
```

## usage

Run `glance` from within a directory and you are immediately serving the files
from within that directory

If the directory being served has a `.glance.json` file within it,
configuration will be read from that. Failing that, glance will look for a
`~/.glance.json` for directives. Failing **that**, glance will use defaults.
Command line options will always override config file options.

## command line options

`glance [options]`

- `--dir, -d <dir>` serve `<dir>` instead of current directory
- `--help, -h` print help screen with option listing
- `--hideindex, -H` don't serve directory listing
- `--indices, -I` comma-separated file names to use as indices
- `--nodot, -n` hide dot files
- `--port, -p <port>` open server on `<port>` rather than 8080
- `--version, -V` print version information
- `--verbose, -v` enable verbose mode, printing log to stdout

## config format

Your config should be valid JSON in the following format (shown with defaults):

```json
{
  "port": 8080,
  "hideindex": false,
  "dir": "/whatever/dir/you/are/in",
  "verbose": false,
  "indices": ["index.html", "index.htm"],
  "nodot": false
}
```

## as a module

Alternatively, you can `require('glance')` and use it as a module within your
own code.

Some sample code might just look something like this:

```js
var http = require('http')

var glance = require('glance')
// init a glance object with custom options (all totally optional)

var g = glance({
  dir: '../Files', // defaults to current working dir
  port: 86753, // defaults to 8080
  indices: [], // use these file names to provide indices
  hideindex: true, // will not provide a directory list if requested
  nodot: true, // will hide dot files from lists and will not serve them
  verbose: true // defaults to false
})

// just use glance to serve requests if you wanna
http
  .createServer(function(req, res) {
    if (/^\/static\//.test(req.url)) {
      return g.serveRequest(req, res)
    }
    // pretend i do other stuff here...
  })
  .listen(5309)

// or, use it to start a static file server
g.start()

// listen for read events
g.on('read', function(req) {
  console.dir(req)
  /* req object of format:
    {
        fullPath: 'requested path'
      , ip: 'remote ip address'
      , method: 'requested method'
      , response: 'response object'
    }
  */
})

// listen for error events
g.on('error', function(req) {
  console.log('BAD!!!!')
  // stop the glance server
  g.stop()
})
```

## license

MIT

---
_Source: https://npm.io/package/glance · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
