Defining a server -- URL+handler function

This commit is contained in:
2024-02-22 10:12:40 -06:00
parent c1cccd7f1f
commit 0cf7052b5d

16
main.go
View File

@@ -1,7 +1,21 @@
package main package main
import "fmt" import (
"fmt"
"io"
"log"
"net/http"
)
func main() { func main() {
fmt.Println("hello world") fmt.Println("hello world")
h1 := func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "Hello World\n")
//io.WriteString(w, r.Method)
}
http.HandleFunc("/", h1)
log.Fatal(http.ListenAndServe(":8000", nil))
} }