main.go 517 B

1234567891011121314151617181920212223242526272829
  1. package main
  2. import (
  3. "fmt"
  4. "io/ioutil"
  5. "net/http"
  6. "os"
  7. )
  8. func serve(w http.ResponseWriter, req *http.Request) {
  9. contents, err := ioutil.ReadFile("install.sh")
  10. if err != nil {
  11. w.WriteHeader(http.StatusInternalServerError)
  12. return
  13. }
  14. w.WriteHeader(http.StatusOK)
  15. w.Header().Add("Content-Type", "text/plain")
  16. w.Write(contents)
  17. }
  18. func main() {
  19. var port string
  20. if port = os.Getenv("PORT"); port == "" {
  21. port = "80"
  22. }
  23. http.HandleFunc("/", serve)
  24. http.ListenAndServe(fmt.Sprintf(":%s", port), nil)
  25. }