Ver código fonte

Обновить 'Server_Golang/main.go'

gr782_lva 3 anos atrás
pai
commit
c70287963a
1 arquivos alterados com 10 adições e 20 exclusões
  1. 10 20
      Server_Golang/main.go

+ 10 - 20
Server_Golang/main.go

@@ -8,36 +8,26 @@ import (
 "time"
 )
 
+
 func main() {
-http.HandleFunc("/", slash) // Добавляем Запрос(Следующие аналогично)
-http.HandleFunc("/ok", ok)
-http.HandleFunc("/info", info)
-http.HandleFunc("/status", status)
-err := http.ListenAndServe(":80", nil) // Ставим порт 80 так как HTTP
+http.HandleFunc("/", slash) // Устанавливаем роутер
+http.HandleFunc("/ok", ok) // Устанавливаем роутер ok
+http.HandleFunc("/info", info) // Устанавливаем роутер info
+http.HandleFunc("/status", status) // Устанавливаем роутер info
+
+err := http.ListenAndServe("localhost:0808", nil) // устанавливаем порт веб-сервера
 if err != nil {
 log.Fatal("ListenAndServe: ", err)
 }
 }
 
 func slash (w http.ResponseWriter,r *http.Request) {
-fmt.Fprint(w,"Если вы видите этот текст, значит это каким то образом работает")
+fmt.Fprint(w,"it alive")
 }
 func ok (w http.ResponseWriter,r *http.Request) {
 w.WriteHeader(http.StatusOK)
-fmt.Fprint(w,"Возвращает для HTTP статус OK")
+fmt.Fprint(w,"http status ok ")
 }
 func info (w http.ResponseWriter,r *http.Request) {
-fmt.Fprint(w,"Выдает информацию о хозяине то есть Ли Владислав")
+fmt.Fprint(w,"LI Vladislave♂")
 }
-
-func status (w http.ResponseWriter,r *http.Request) {
-var remoteIp = r.RemoteAddr
-var splitIp = strings.Split(remoteIp, ".")
-var fmtIP = fmt.Sprint(splitIp[0], ".x.x.", strings.Split(splitIp[3], ":")[0])
-
-var fmtDate = time.Now().Format("2006-01-02 3:4:5 pm")
-
-fmt.Fprintf(w,"Ли Владислав\n")
-fmt.Fprintf(w, fmtDate + "\n")
-fmt.Fprintf(w, fmtIP)
-}