test.go 465 B

1234567891011121314151617181920212223
  1. package main
  2. import (
  3. "fmt"
  4. "log"
  5. "net/http"
  6. )
  7. func main() {
  8. http.HandleFunc("/ok", sayhello)
  9. http.HandleFunc("/info", sayhello1)
  10. err := http.ListenAndServe(":8080", nil)
  11. if err != nil {
  12. log.Fatal("ListenAndServe: ", err)
  13. }
  14. }
  15. func sayhello(w http.ResponseWriter, r *http.Request) {
  16. fmt.Fprintf(w, "ok")
  17. w.WriteHeader(200)
  18. }
  19. func sayhello1(w http.ResponseWriter, r *http.Request) {
  20. fmt.Fprintf(w, "Морозов М.А. 792")
  21. }