From d7d8bf4b201785ecd2106d84358304b0ba928e54 Mon Sep 17 00:00:00 2001 From: s441433 Date: Mon, 17 Dec 2018 22:35:22 +0100 Subject: [PATCH] Update main.go --- main.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 2dd05bf..286b43f 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,8 @@ func sayhelloName(w http.ResponseWriter, r *http.Request) { fmt.Println("key:", k) fmt.Println("val:", strings.Join(v, "")) } - fmt.Fprintf(w, "Hello astaxie!") + fmt.Fprintf(w, "Witaj, aby przejść do panelu logowania przejdź odpowiednio do Login!") + fmt.Println("path", r.URL.Path, w, "/login") } func login(w http.ResponseWriter, r *http.Request) { @@ -33,9 +34,22 @@ func login(w http.ResponseWriter, r *http.Request) { } } +func panel(w http.ResponseWriter, r *http.Request) { + fmt.Println("method:", r.Method) + if r.Method == "GET" { + t, _ := template.ParseFiles("panel.gtpl") + t.Execute(w, nil) + } else { + r.ParseForm() + fmt.Println("username:", r.Form["username"]) + fmt.Println("password:", r.Form["password"]) + } +} + func main() { http.HandleFunc("/", sayhelloName) http.HandleFunc("/login", login) + http.HandleFunc("/panel", panel) err := http.ListenAndServe(":9197", nil) if err != nil { log.Fatal("ListenAndServe: ", err)