|
|
|
@ -1,26 +1,25 @@
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
|
|
|
|
"fmt"
|
|
|
|
|
"net/http"
|
|
|
|
|
"log"
|
|
|
|
|
"fmt"
|
|
|
|
|
"log"
|
|
|
|
|
"net/http"
|
|
|
|
|
"os"
|
|
|
|
|
"runtime"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
port := os.Getenv("PORT")
|
|
|
|
|
if port == "" {
|
|
|
|
|
port = "8080"
|
|
|
|
|
}
|
|
|
|
|
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\n", hostname)
|
|
|
|
|
})
|
|
|
|
|
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))
|
|
|
|
|
log.Fatal(http.ListenAndServe(":"+port, nil))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|