main1.go 513 B

123456789101112131415161718192021222324
  1. package main
  2. import (
  3. "fmt"
  4. "log"
  5. "net/http"
  6. )
  7. func main() {
  8. http.HandleFunc("/info", sayhello) //сама страница
  9. http.HandleFunc("/Ok", ok)
  10. err := http.ListenAndServe(":8080", nil)
  11. if err != nil {
  12. log.Fatal("ListenAndServe: ", err) //выводит ошибку 404
  13. }
  14. }
  15. func sayhello(w http.ResponseWriter, r *http.Request) {
  16. fmt.Fprintf(w, "Hello world im Kirill 792")
  17. }
  18. func ok(w http.ResponseWriter, r *http.Request) {
  19. fmt.Fprintf(w, "http status: 200 Ok")
  20. }