diff --git a/xx-http-client.go b/xx-http-client.go new file mode 100644 index 0000000..a2c6b39 --- /dev/null +++ b/xx-http-client.go @@ -0,0 +1,13 @@ +package main + +import ("net/http"; "io/ioutil"; "fmt") + +func main() { + resp, err := http.Get("http://127.0.0.1:5000/") + if err != nil { + panic(err) + } + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + fmt.Print(string(body)) +} diff --git a/xx-http-server.go b/xx-http-server.go new file mode 100644 index 0000000..da78c74 --- /dev/null +++ b/xx-http-server.go @@ -0,0 +1,13 @@ +package main + +import ("net/http"; "io") + +func hello(res http.ResponseWriter, req *http.Request) { + res.Header().Set("Content-Type", "text/plain") + io.WriteString(res, "Hello From HTTP\n") +} + +func main() { + http.HandleFunc("/", hello) + http.ListenAndServe(":5000", nil) +}