Skip to content

Instantly share code, notes, and snippets.

@treeder
Last active September 27, 2019 17:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save treeder/992278b7f3a05ee680c559f2714baa69 to your computer and use it in GitHub Desktop.
Save treeder/992278b7f3a05ee680c559f2714baa69 to your computer and use it in GitHub Desktop.
package main
import (
"io"
"log"
"net/http"
"os"
)
func hello(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "Hello world!")
}
func main() {
http.HandleFunc("/", hello)
port := os.Getenv("PORT") // Heroku provides the port to bind to
if port == "" {
port = "8080"
}
log.Fatal(http.ListenAndServe(":"+port, nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment