12345678910111213141516171819202122232425262728293031323334353637383940 |
- package main
- import(
- "fmt"
- "log"
- "net/http"
- "net"
- "regexp"
- "time"
- )
- func main() {
- http.HandleFunc("/Info", info)
- http.HandleFunc("/Ok", ok)
- http.HandleFunc("/status", status)
- err := http.ListenAndServe(":8080",nil)
- if err != nil {
- log.Fatal("ListenAndServe: ", err)
- }
- }
- func ok(w http.ResponseWriter, r *http.Request){
- fmt.Fprintf(w, "http status: 200")
- }
- func info(w http.ResponseWriter, r *http.Request){
- fmt.Fprintf(w, "Привет, студент группы 792, Мотрев Никита Дмитриевич ")
- }
- func status(w http.ResponseWriter, r *http.Request){
- dt := time.Now()
- ip,_,_:=net.SplitHostPort(r.RemoteAddr)
- res := regexp.MustCompile(`[.]\d[.]\d[.]`)
- fmt.Fprintln(w,res.ReplaceAllString(ip,".*.*."))
- fmt.Fprintf(w,"Мотрев Никита Дмитриевич\n")
- fmt.Fprintf(w, dt.Format("2006-01-02 3:4:5 pm"))
- }
|