GitHub - syntaqx/serve: a static http server anywhere you need one.
source link: https://github.com/syntaqx/serve
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
TL;DR
It's basically
python -m SimpleHTTPServer 8080
written in Go, because who can remember that many letters?
Installation
serve
can be installed in a handful of ways:
Homebrew on macOS
If you are using Homebrew on macOS, you can install serve
with the
following command:
brew install syntaqx/tap/serve
Download the binary
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
.
From source
To build from source, check out the instructions on getting started with development.
Usage
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.
Options
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]
)
Development
To develop serve
or interact with its source code in any meaningful way, be
sure you have the following installed:
Prerequisites
You will need to activate Modules for your version of Go, generally
by invoking go
with the support GO111MODULE=on
environment variable set.
Install
You can download and install the project from GitHub by simply running:
git clone [email protected]: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
Using serve
manually
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)) }
License
serve
is open source software released under the MIT license.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK