// Homework 32, problem 2: An HTML page. // // Reply at / with an HTML page that has a heading, a paragraph, and a list of // three things you like. Set the Content-Type header so that the browser reads // it as HTML, and keep the HTML in a constant. // // Run with: go run exercises/41/homework/02-html-page.go package main import ( "fmt" "net/http" ) // TODO: add a constant holding the page here. func handleHome(w http.ResponseWriter, r *http.Request) { // TODO: set the header and send the page, in place of this placeholder line: fmt.Fprintln(w, "TODO: replace this line") } func main() { http.HandleFunc("GET /{$}", handleHome) 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) } }