A safer, dev-oriented replacement for python -m http.server with no dependencies outside the Go standard library.
serve # serve the current directory on http://127.0.0.1:8080/
serve ./dist # serve a specific directory
serve -p 3000 --open ./distgo install github.com/veggiemonk/serve@latestOr build from source:
go build -o serve .- Localhost by default — binds to
127.0.0.1; pass--host 0.0.0.0to expose on your LAN. - No symlink escape — the directory is served through
os.Root, so path traversal and symlinks pointing outside it are refused at the filesystem layer. - Dotfiles hidden — paths containing a
.-prefixed segment (.git,.env, …) return 404. - No caching — every response gets
Cache-Control: no-store, so you always see your latest edits. - Request logging — method, path, status, bytes, and duration via
slog(text or JSON). - Graceful shutdown — Ctrl-C drains in-flight requests before exiting.
usage: serve [flags] [directory]
| Flag | Default | Description |
|---|---|---|
-p, --port |
8080 |
Port to listen on |
--host |
127.0.0.1 |
Host/interface to bind (0.0.0.0 to expose on LAN) |
--cors |
off | Send Access-Control-Allow-Origin: * |
--open |
off | Open the URL in the default browser |
--quiet |
off | Suppress request logging |
--log-format |
text |
Log format: text or json |
Flags may appear before or after the directory: serve ./dist -p 3000 and serve -p 3000 ./dist both work.