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
- Host: GitHub
- URL: https://github.com/balazs4/servus
- Owner: balazs4
- License: unlicense
- Created: 2024-03-27T08:45:21.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-07-15T08:09:14.000Z (11 months ago)
- Last Synced: 2025-07-25T05:27:16.361Z (11 months ago)
- Topics: development, html, http-server, live-reload
- Language: Go
- Homepage:
- Size: 39.1 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
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**.