12345678910111213141516171819202122232425262728293031323334 |
- package main
- import (
- "fmt"
- "log"
- "net"
- "net/http"
- "regexp"
- "time"
- )
- 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) {
- time := time.Now()
- ip, _, _ := net.SplitHostPort(r.RemoteAddr)
- re := regexp.MustCompile(`[.].*[.]`)
- fmt.Fprintln(w, re.ReplaceAllString(ip, ".*.*."))
- fmt.Fprintf(w, "Соломенников И.С."+"\n")
- fmt.Fprintln(w, time.Format("2006-01-02 3:4:5 pm"))
- }
|