From 1a2331bed677c0826a683e947a7827b0fb856cbb Mon Sep 17 00:00:00 2001 From: s441433 Date: Fri, 28 Dec 2018 14:22:11 +0100 Subject: [PATCH] Update main.go --- main.go | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/main.go b/main.go index 2f9c6cd..0bdd5bd 100644 --- a/main.go +++ b/main.go @@ -9,18 +9,8 @@ import ( ) func opisStołówkaZPM(w http.ResponseWriter, r *http.Request) { - t, _ := template.ParseFiles("StronaGlowna.tmpl") + t, _ := template.ParseFiles("StronaGlowna.gtpl") t.Execute(w, nil) - //r.ParseForm() - //fmt.Println(r.Form) - //fmt.Println("path", r.URL.Path) - //fmt.Println("scheme", r.URL.Scheme) - //fmt.Println(r.Form["url_long"]) - //for k, v := range r.Form { - // fmt.Println("key:", k) - // fmt.Println("val:", strings.Join(v, "")) - //} - } func panel(w http.ResponseWriter, r *http.Request) { @@ -30,19 +20,19 @@ func panel(w http.ResponseWriter, r *http.Request) { } func login(w http.ResponseWriter, r *http.Request) { +Here: fmt.Println("method:", r.Method) if r.Method == "GET" { - t, _ := template.ParseFiles("login.html") + t, _ := template.ParseFiles("login.gtpl") t.Execute(w, nil) } else { r.ParseForm() fmt.Println("username:", r.Form["username"]) fmt.Println("password:", r.Form["password"]) + if len(r.Form["username"][0]) == 0 { + goto Here + } } - //if r.Method == "POST" { - // t, _ := template.ParseFiles("panel.gtpl") - // t.Execute(w, nil) - //} username := r.Form["username"] password := r.Form["password"] zaloguj := "Wpisane wartości:"