You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
"os"
|
|
|
|
"runtime"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
port := os.Getenv("PORT")
|
|
|
|
if port == "" {
|
|
|
|
port = "8080"
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Fprintf(os.Stdout, "Listening on :%s\n", port)
|
|
|
|
hostname, _ := os.Hostname()
|
|
|
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
fmt.Fprintf(os.Stdout, "I'm %s\n", hostname)
|
|
|
|
fmt.Fprintf(w, "I'm %s running on %s/%s\n", hostname, runtime.GOOS, runtime.GOARCH)
|
|
|
|
})
|
|
|
|
|
|
|
|
log.Fatal(http.ListenAndServe(":"+port, nil))
|
|
|
|
}
|