serve是一个您需要的静态http服务器

serve是一个您需要的静态http服务器

Go 服务器应用

访问GitHub主页

共223Star

详细介绍

img

serve is a static http server anywhere you need one.

GoDoc Build Status codecov Go Report Card Mentioned in Awesome Go

Pre-Release



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 to 0.0.0.0)
  • --port listening port (defaults to 8080)
  • --ssl enable https (defaults to false)
  • --cert path to the ssl cert file (defaults to cert.pem)
  • --key path to the ssl key file (defaults to key.pem)
  • --dir directory path to serve (defaults to ., also configurable by arg[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 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

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.