Defining a server -- URL+handler function
This commit is contained in:
16
main.go
16
main.go
@@ -1,7 +1,21 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user