An open API service indexing awesome lists of open source software.

https://github.com/balazs4/servus

http server with built-in auto refresh on file changes
https://github.com/balazs4/servus

development html http-server live-reload

Last synced: 4 months ago
JSON representation

http server with built-in auto refresh on file changes

Awesome Lists containing this project

README

          

# servus

> HTTP server with built-in automatic refresh feature on file changes for developers.

## Features

- Serves static files from the current directory or specified files
- Automatic browser refresh on file changes (live reload)
- Watches files/directories for changes using [fsnotify](https://github.com/fsnotify/fsnotify)
- Injects a live reload script into served HTML files
- Customizable port via the `PORT` environment variable (default: 3000)
- Simple logging with version info

## How it works

When you run `servus`, it starts an HTTP server and watches the current directory (or specified files/directories) for changes. When a file changes, connected browsers are notified via a Server-Sent Events (SSE) endpoint (`/.servus`). A small script is injected into served HTML files, which listens for these events and reloads the page automatically.

## Usage

```sh
servus # watches current directory (non-recursive)
servus `git ls-files` # watches all files in git repository
PORT=4269 servus # set custom port number
```

## Endpoints

- `GET /` — Redirects to `/index.html`
- `GET /{file}` — Serves the requested file from the current directory
- `GET /.servus` — Server-Sent Events endpoint for live reload notifications

## Install

```sh
go install github.com/balazs4/servus
```

Or download a [pre-built binary](https://github.com/balazs4/servus/releases).

## Example

Start the server:

```sh
servus
```

Open your browser to [http://localhost:3000](http://localhost:3000). When you edit and save an HTML file, the page will automatically reload.

## License

See [license](./license)

## Author

balazs4

> **Note:** This readme.md was generated by AI ([opencode](https://github.com/sst/opencode) v0.3.5, model: github-copilot/gpt-4.1), but all code is **100% manually written**.