// Homework 34, problem 3: A safe greeting. // // GET /greet?name=Keiko shows "Hello, Keiko!" on an HTML page. Use a template, // so that a name such as Keiko shows up as text and not as bold. Check it // with curl.exe, and look for < in the reply. A missing or empty name replies // with status 400. // // Run with: go run exercises/34/homework/03-safe-greeting.go package main import ( "fmt" "net/http" ) // TODO: add the struct, the template, and html/template to the imports. func handleGreet(w http.ResponseWriter, r *http.Request) { // TODO: write your code here, in place of this placeholder line: fmt.Fprintln(w, "TODO: replace this line") } func main() { http.HandleFunc("GET /greet", handleGreet) fmt.Println("Server running at http://localhost:8080") fmt.Println("Press Ctrl+C to stop it.") err := http.ListenAndServe("localhost:8080", nil) if err != nil { fmt.Println("Server stopped:", err) } }