package main import ( "encoding/json" "fmt" "log" "net/http" "os" "time" ) func main() { port := os.Getenv("PORT") if port == "" { port = "8080" } http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(map[string]interface{}{ "status": "online", "app": "Cosmos Orbit — Go Lightweight Web Server", "timestamp": time.Now().Format(time.RFC3339), }) }) http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Write([]byte("OK")) }) log.Printf("Go server listening on port %s", port) if err := http.ListenAndServe(fmt.Sprintf(":%s", port), nil); err != nil { log.Fatal(err) } }