package main import ( "fmt" "net" "net/http" ) func getMyIP(w http.ResponseWriter, r *http.Request) { host, _, _ := net.SplitHostPort(r.RemoteAddr) fmt.Fprint(w, host) fmt.Printf("Received request from %s\n", host) } func main() { fmt.Println("Server running on 0.0.0.0:5000") http.HandleFunc("/", getMyIP) if err := http.ListenAndServe("0.0.0.0:5000", nil); err != nil { panic(err) } }