28 lines
419 B
Go
28 lines
419 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"log"
|
||
|
"net/http"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
func handler(w http.ResponseWriter, r *http.Request) {
|
||
|
target := os.Getenv("TARGET")
|
||
|
if target == "" {
|
||
|
target = "World"
|
||
|
}
|
||
|
fmt.Fprintf(w, "Hello %s!\n", target)
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
http.HandleFunc("/", handler)
|
||
|
|
||
|
port := os.Getenv("PORT")
|
||
|
if port == "" {
|
||
|
port = "8080"
|
||
|
}
|
||
|
|
||
|
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))
|
||
|
}
|