main.go 589 B

1234567891011121314151617181920212223242526
  1. package main
  2. import (
  3. "fmt"
  4. "log"
  5. "net/http"
  6. )
  7. func sayhello(w http.ResponseWriter, r *http.Request) {
  8. fmt.Fprintf(w, "HTTP-статус 200")
  9. }
  10. func sayinfo(w http.ResponseWriter, r *http.Request) {
  11. fmt.Fprintf(w, "НИВ 794")
  12. }
  13. func sayOK(w http.ResponseWriter, r *http.Request) {
  14. fmt.Fprintf(w, "OK")
  15. }
  16. func main() {
  17. http.HandleFunc("/info", sayinfo)
  18. http.HandleFunc("/", sayhello)
  19. http.HandleFunc("/OK", sayOK)
  20. err := http.ListenAndServe(":8080", nil) // устанавливаем порт веб-сервера
  21. if err != nil {
  22. log.Fatal("ListenAndServe: ", err)
  23. }
  24. }