Sfoglia il codice sorgente

Удалить 'main_2.go'

gr794_pal 2 anni fa
parent
commit
2cd9cad605
1 ha cambiato i file con 0 aggiunte e 39 eliminazioni
  1. 0 39
      main_2.go

+ 0 - 39
main_2.go

@@ -1,39 +0,0 @@
-package main
-
-import (
-	"fmt"
-	"io"
-	"net/http"
-	"regexp"
-	"time"
-)
-
-func main() {
-	http.HandleFunc("/status", status)
-	http.ListenAndServe(":8080", nil)
-
-}
-
-var re = regexp.MustCompile("(\\d+\\.)(\\d+\\.\\d+)(\\.\\d+)")
-
-func status(w http.ResponseWriter, r *http.Request) {
-	fmt.Fprintf(w, "PAL\n")
-	// make GET request
-	response, error := http.Get("https://api.ipify.org/?format=text")
-	if error != nil {
-		fmt.Println(error)
-	}
-
-	// read response body
-	body, error := io.ReadAll(response.Body)
-	if error != nil {
-		fmt.Println(error)
-	}
-
-	response.Body.Close()
-
-	out := re.ReplaceAllString(string(body), "$1***.***$3")
-	fmt.Fprint(w, "IP-address: ", out, "\n")
-	now := time.Now()
-	fmt.Fprintf(w, now.Format("2006-01-02 3:4:5 pm"))
-}