Skip to content

Instantly share code, notes, and snippets.

@Mikubill
Last active March 13, 2023 01:10
Show Gist options
  • Save Mikubill/4128ba5240403b7173e6d899bb875b7f to your computer and use it in GitHub Desktop.
Save Mikubill/4128ba5240403b7173e6d899bb875b7f to your computer and use it in GitHub Desktop.
Golang Simple HTTP Server
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