main.go 674 B

123456789101112131415161718192021222324252627
  1. package main
  2. import (
  3. "fmt"
  4. "net/http"
  5. "log"
  6. )
  7. func main() {
  8. http.HandleFunc("/", sayhello) // Устанавливаем роутер
  9. http.HandleFunc("/home", sayhello1)
  10. http.HandleFunc("/omegalul", sayhello2)
  11. err := http.ListenAndServe(":8080", nil) // устанавливаем порт веб-сервера
  12. if err != nil {
  13. log.Fatal("ListenAndServe: ", err)
  14. }
  15. }
  16. func sayhello(w http.ResponseWriter, r *http.Request) {
  17. fmt.Fprintf(w, "Привет!")
  18. }
  19. func sayhello1(w http.ResponseWriter, r *http.Request) {
  20. fmt.Fprintf(w, "darova ept eto home!")
  21. }
  22. func sayhello2(w http.ResponseWriter, r *http.Request) {
  23. fmt.Fprintf(w, "kekwait")
  24. }