static-server
is a simple command line app written in Go that serves your current working directory as a static server.
- No external dependencies are used. The project leverages native Go packages only.
- No external runtime dependencies. Some CLI tools require you to have a specific version of Node.js, Python or another language, this does not.
- Multi-platform: Thanks to Go, this works on macOS, Windows and Linux
If you have Go lang tooling installed, this is the way that is recommended since it will build the binary for your architecture and make it executable.
Install the CLI tool using go install
:
go install github.com/tinacious/static-server@latest
Go to the releases page and download the appropriate release for your operating system and architecture.
Put the file somewhere on your executables path, e.g. I use ~/.local/bin
.
On macOS, you will need to trust the executable after the first run attempt in your System Preferences β Privacy & Security settings.
Run the static-server
command in any directory you'd like to serve as a web server.
If you have the following directory test
:
test
βββ index.html
βββ style.css
You can do:
cd test
static-server
This should serve the contents on a random port.
You can configure the port by passing it as an environment variable. For example, to run on port 1337 run:
PORT=1337 static-server
To uninstall it, simply delete the executable static-server
.
If you installed it with Go, you can navigate to either $GOPATH/bin
(if your $GOPATH
is defined) or ~/go/bin
and delete it from there.
If you installed it manually, e.g. in ~/.local/bin
, delete it from there.