hello_server.go 337 B

12345678910111213141516171819
  1. // hello_server.go
  2. package main
  3. import (
  4. "fmt"
  5. "net/http"
  6. )
  7. type Hello struct{}
  8. func (h Hello) ServeHTTP(w http.ResponseWriter, r *http.Request) {
  9. fmt.Fprint(w, "Hello!")
  10. }
  11. func main() {
  12. var h Hello
  13. http.ListenAndServe("localhost:4000",h)
  14. }
  15. // Output in browser-window with url http://localhost:4000: Hello!