Last active
September 27, 2019 17:41
-
-
Save treeder/992278b7f3a05ee680c559f2714baa69 to your computer and use it in GitHub Desktop.
This file contains 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 ( | |
"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