Last active
February 7, 2018 14:13
-
-
Save windhc/d20d7c95e13aed68d214c8f7506b6f51 to your computer and use it in GitHub Desktop.
go简单静态页面服务
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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