Skip to content

Instantly share code, notes, and snippets.

@cezarsa
Created August 13, 2015 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cezarsa/398804c01ee3885fa8b2 to your computer and use it in GitHub Desktop.
Save cezarsa/398804c01ee3885fa8b2 to your computer and use it in GitHub Desktop.
basic
package main
import (
"fmt"
"net/http"
"os"
)
func rootHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("hello world"))
}
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8888"
}
fmt.Println("listening on", port)
http.ListenAndServe("0.0.0.0:"+port, http.HandlerFunc(rootHandler))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment