It's basically
python -m SimpleHTTPServer 8080
written in Go, because who can remember that many letters?
serve
can be installed in a handful of ways:
If you are using Homebrew on macOS, you can install serve
with the
following command:
brew install syntaqx/tap/serve
Quickly download install the latest release:
curl -sfL https://install.goreleaser.com/github.com/syntaqx/serve.sh | sh
Or manually download the latest release binary for your system and
architecture and install it into your $PATH
.
To build from source, check out the instructions on getting started with development.
serve [options] [path]
[path]
defaults to.
(relative path to the current directory)
Then simply open your browser to http://localhost:8080 to view your server.
The following configuration options are available:
--host
host address to bind to (defaults to0.0.0.0
)--port
listening port (defaults to8080
)--ssl
enable https (defaults tofalse
)--cert
path to the ssl cert file (defaults tocert.pem
)--key
path to the ssl key file (defaults tokey.pem
)--dir
directory path to serve (defaults to.
, also configurable byarg[0]
)
To develop serve
or interact with its source code in any meaningful way, be
sure you have the following installed:
You will need to activate Modules for your version of Go, generally
by invoking go
with the support GO111MODULE=on
environment variable set.
You can download and install the project from GitHub by simply running:
git clone git@github.com:syntaqx/serve.git && cd $(basename $_ .git)
make install
This will install serve
into your $GOPATH/bin
directory, which assuming is
properly appended to your $PATH
, can now be used:
$ serve version
serve version v0.0.6-8-g5074d63 windows/amd64
Besides running serve
using the provided binary, you can also embed a
serve.FileServer
into your own Go program:
package main
import (
"log"
"net/http"
"github.com/syntaqx/serve"
)
func main() {
fs := serve.NewFileServer()
log.Fatal(http.ListenAndServe(":8080", fs))
}
serve
is open source software released under the MIT license.