Skip to content

Instantly share code, notes, and snippets.

@windhc
Last active February 7, 2018 14:13
Show Gist options
  • Save windhc/d20d7c95e13aed68d214c8f7506b6f51 to your computer and use it in GitHub Desktop.
Save windhc/d20d7c95e13aed68d214c8f7506b6f51 to your computer and use it in GitHub Desktop.
go简单静态页面服务
package main
import (
"log"
"net/http"
)
func main() {
port := ":8000"
log.Printf("Serving at: http://localhost%s\n", port)
http.Handle("/", http.FileServer(http.Dir("dist/")))
err := http.ListenAndServe(port, nil)
if err != nil {
log.Fatal("ListenAndServe fail:", err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment