Last active
March 13, 2023 01:10
-
-
Save Mikubill/4128ba5240403b7173e6d899bb875b7f to your computer and use it in GitHub Desktop.
Golang Simple HTTP Server
This file contains hidden or 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() { | |
mux := http.NewServeMux() | |
mux.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) { | |
http.ServeFile(writer, request, request.URL.Path[1:]) | |
}) | |
server := http.Server{Addr: ":80", Handler: mux} | |
log.Println(server.ListenAndServe()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment