# cli-http-server

> A local web server is a command line application for serving static web pages on a local developmeant machine. It watches for file change and refresh your page.

Latest version **1.3.3** (published 2023-09-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install cli-http-server
pnpm add cli-http-server
yarn add cli-http-server
bun add cli-http-server
```

Provides the command `serverlc`.

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.3 |
| Published | 2023-09-20 |
| First published | 2023-07-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 96.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ikechukwu Ajike |
| Maintainers | unique_iyke |
| Keywords | cli, server, serverlc, http, web, commander, ws |

## Links

- npm: https://www.npmjs.com/package/cli-http-server
- Repository: https://github.com/uniqueiyke/cli-http-server
- Homepage: https://github.com/uniqueiyke/cli-http-server#readme
- Issues: https://github.com/uniqueiyke/cli-http-server/issues
- npm.io page: https://npm.io/package/cli-http-server

## Dependencies (2)

- [ws](https://npm.io/package/ws.md) ^8.13.0
- [commander](https://npm.io/package/commander.md) ^11.0.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.3.3 (latest) — 2023-09-20
- 1.3.2 — 2023-09-20
- 1.3.1 — 2023-09-17
- 1.3.0 — 2023-07-22
- 1.2.3 — 2023-07-21
- 1.2.2 — 2023-07-21
- 1.2.1 — 2023-07-21
- 1.2.0 — 2023-07-21

## README

# cli-http-server

A local web server is a command line application for serving static web pages on a local developmeant machine. It watches for file change and refresh your page.


## Installation

`npm install cli-http-server`

## Usage
Install the package globally using the npm installation command

##### install via npm
`npm i -g cli-http-server`

##### install via yarn
`yarn global add cli-http-server`

Start the server by cd to you project folder and running the command `serverlc` on the command line window.

### To Start Server
run `serverlc` on the cli window. Make sure you are running the command on your project directory. If your run the command on another directory other than your project directory, then you have to pass the full path to your project directory as an option us using `--dir` or `-d` cli option.
Example `serverlc --dir='C:/some-folder/anoter-folder/this-folder'` Where this-folder should be the main folder that contains your project

When the above command is ran on the cli window, the server will start on the default port of 9696 on your development machine. You can change the port by using `--port` or `-p` cli option. e.g `serverlc --port=3030`

when the starts, it will serve any index.html file on the  current working directory as the home page. That is `localhost:port/` will default to any index.html file on your project folder. If you do not have any file named index.html or you want to use to another file, you can pass the file name to the cli option `--index` or `-i`. e.g  `serverlc -i=app.html`.
You can navigate to other pages by using the relative path to the file as the url. e.g `localhost:port/about` will server the about.html file the `<root>` directory while `localhost:port/page/about` will serve the about.html file in the `<root>/page` folder.
If you want the server to serve any other file type other than .html file, then you have to include the file extention as in `localhost:port/my-image.png` or `localhost:port/pgk.json`.

### cli options:

| Option | Description |
| -------- | ---------- |
| -v, --version | Print the app version |
| -d, --dir <string> | The full path to the directory that contains your static assets (default: C:/current/working/directory) |
| -i, --index <string> | The file name of the html file to be served as the index (or root) file - home page  by the server. (default: index.html) |
| -p, --port <number> | The port on which the server serves the html file. (default: 9696) |
| -o, --open <boolean> | Open a browser when the server start. Default true (default: true) |
| -no-o, --no-open | Do not open a browser when the server start. |
| -w, --watch <boolean> | watch for file change and refresh the browser after ward. (default: true) |
| -no-w, --no-watch | Disable browser resresh on file change. |
| -h, --help | display help for command |

## License
License under the
[MIT](https://github.com/uniqueiyke/cli-http-server/blob/main/LICENSE)

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