1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package main
- import (
- "fmt"
- "ip/ioutil"
- "regexp"
- "time"
- "log"
- "net/http"
- )
- func main() {
- http.HandleFunc("/dsaw", ggwp)
- http.HandleFunc("/wasd", saydayn)
- http.HandleFunc("/status", statusip)
- err := http.ListenAndServe(":8081", nil)
- if err != nil {
- log.Fatal("ListenAndServe: ", err)
- }
- }
- func ggwp(w http.ResponseWriter, r *http.Request) {
- fmt.Fprintf(w, "Соломенников Илья Сергеевич")
- }
- func saydayn(w http.ResponseWriter, r *http.Request) {
- fmt.Fprintf(w, "скажите вместе даун")
- }
- func statusip(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"))
- mi:=regexp.MustCompile("[.].+[.]")
- ma:string(ip)
- qwe:=mi.ReplaceAllString(ma,",aiai,aiai,")
- fmt.Fprintf(w,"\n%s",qwe)
- }
|