package main import ( "fmt" "io/ioutil" "log" "net/http" "os" ) func main() { port := os.Getenv("PORT") if port == "" { port = "80" } http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Header().Set("Content-Type", "text/html; charset=utf-8") file, err := ioutil.ReadFile("./assets/init.html") if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) log.Fatal("Can't find error html page") } w.Write(file) }) // return 200 on healthz path http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Write([]byte("healthy!")) }) if err := http.ListenAndServe(fmt.Sprintf(":%s", port), nil); err != nil { panic(err) } }