123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package main
- import (
- "fmt"
- "io/ioutil"
- "log"
- "net/http"
- "regexp"
- "time"
- )
- func main() {
- gugugaga()
- }
- func gugugaga() {
- http.HandleFunc("/ok/", status200)
- http.HandleFunc("/info/", information)
- http.HandleFunc("/status/", status)
- err := http.ListenAndServe(":7070", nil)
- if err != nil {
- log.Fatal("ListenAndServer:", err)
- return
- }
- }
- func status200(w http.ResponseWriter, r *http.Request) {
- w.Write([]byte("статус 200"))
- }
- func information(w http.ResponseWriter, r *http.Request) {
- w.Write([]byte("группа 792(4)\n Варламов Алексей"))
- }
- func status(w http.ResponseWriter, r *http.Request) {
- res, _ := http.Get("https://api.ipify.org/")
- ip, err := ioutil.ReadAll(res.Body)
- if err != nil {
- return
- }
- fmt.Fprintf(w, "%s\n", ip)
- today := time.Now()
- fmt.Fprintf(w, today.Format("2006-01-02 3:4:5 pm"))
- reg := regexp.MustCompile("[.].+[.]")
- out := string(ip)
- ewq := reg.ReplaceAllString(out, ".o.o.")
- fmt.Fprintf(w, "\n%s", ewq)
- }
|