Thanks to visit codestin.com
Credit goes to github.com

Skip to content

balazs4/servus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
  • 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

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

go install github.com/balazs4/servus

Or download a pre-built binary.

Example

Start the server:

servus

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

License

See license

Author

balazs4

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

About

http server with built-in auto refresh on file changes

Topics

Resources

License

Stars

Watchers

Forks