// Chapter 33 example: UNSAFE on purpose. This server prints visitor input // straight into HTML, so that you can see what goes wrong. Chapter 34 fixes it. // Do not copy this handler into a real program. // Run with: go run exercises/33/04-unsafe-echo.go package main import ( "fmt" "net/http" ) func handleEcho(w http.ResponseWriter, r *http.Request) { text := r.URL.Query().Get("text") w.Header().Set("Content-Type", "text/html; charset=utf-8") fmt.Fprintf(w, "

You said: %s

\n", text) } func main() { http.HandleFunc("GET /echo", handleEcho) 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) } }