Skip to content

clavinjune/serve

Repository files navigation

Serve

Go Version Reference Go Report Card Latest Release Registry License

A Lightweight HTTP Server Built on Top of Go

Run

Via Download

  • Download from here
Operating System Name Format
MacOS serve_{version}_darwin_{arch}
Linux serve_{version}_linux_{arch}
Windows serve_{version}_windows_{arch}.exe
  • For MacOS and Linux, make the file executable
# chmod +x serve_{version}_{os}_{arch}
$ wget https://github.com/clavinjune/serve/releases/download/v1.0.2/serve_1.0.2_darwin_arm64
$ chmod +x serve_1.0.2_darwin_arm64
$ ./serve_1.0.2_darwin_arm64 -v
serve 1.0.2-0d66413211647f62769a52854979cb84af398b62 darwin/arm64 BuildBy=goreleaser BuildDate=2022-04-15T22:09:06Z

Via Go Install

$ go install github.com/clavinjune/serve@latest
go: downloading github.com/clavinjune/serve v1.0.2
$ serve -v
serve dev-n/a darwin/arm64 BuildBy=dev BuildDate=0001-01-01 00:00:00 +0000 UTC

Via Go Run

$ go run github.com/clavinjune/serve@latest -v
serve dev-n/a darwin/arm64 BuildBy=dev BuildDate=0001-01-01 00:00:00 +0000 UTC

Via Docker

$ docker run --rm ghcr.io/clavinjune/serve:latest -v
serve 1.0.2-0d66413211647f62769a52854979cb84af398b62 linux/arm64 BuildBy=goreleaser BuildDate=2022-04-15T22:09:06Z

Via Podman

$ podman run --rm ghcr.io/clavinjune/serve:latest -v
serve 1.0.2-0d66413211647f62769a52854979cb84af398b62 linux/arm64 BuildBy=goreleaser BuildDate=2022-04-15T22:09:06Z

Usage

$ serve -h
Usage of serve:
  -p int
        port on which the server will listen (default 1313)
  -q    run server quietly
  -r string
        root document which the server will serve (default ".")
  -s    serve single page application
  -v    print current version

Example

$ podman run --rm \
> -v /tmp/foo:/app/src \
> -p 1313:1313 \
> ghcr.io/clavinjune/serve:latest
2021/11/04 06:32:19 listen and serve /app/src/ at http://0.0.0.0:1313
2021/11/04 06:32:23 / 46.107µs
2021/11/04 06:32:23 /favicon.ico 78.868µs
2021/11/04 06:32:40 /index.html 6.642µs
2021/11/04 06:32:40 / 31.058µs
2021/11/04 06:32:44 /foo/ 60.574µs