61 lines
1.3 KiB
Go
61 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"html/template"
|
|
"log"
|
|
"net/http"
|
|
//"strings"
|
|
)
|
|
|
|
func opisStołówkaZPM(w http.ResponseWriter, r *http.Request) {
|
|
t, _ := template.ParseFiles("StronaGlowna.gtpl")
|
|
t.Execute(w, nil)
|
|
}
|
|
|
|
func panel(w http.ResponseWriter, r *http.Request) {
|
|
fmt.Println("method:", r.Method)
|
|
t, _ := template.ParseFiles("panel.gtpl")
|
|
t.Execute(w, nil)
|
|
}
|
|
|
|
func login(w http.ResponseWriter, r *http.Request) {
|
|
Here:
|
|
fmt.Println("method:", r.Method)
|
|
if r.Method == "GET" {
|
|
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 len(r.Form["password"][0]) == 0 {
|
|
// goto Here
|
|
//}
|
|
}
|
|
username := r.Form["username"]
|
|
password := r.Form["password"]
|
|
zaloguj := "Wpisane wartości:"
|
|
if r.Method == "POST" {
|
|
if zaloguj != "" {
|
|
fmt.Fprintln(w, zaloguj)
|
|
fmt.Fprintln(w, username)
|
|
fmt.Fprintln(w, password)
|
|
}
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
http.HandleFunc("/", opisStołówkaZPM)
|
|
http.HandleFunc("/login", login)
|
|
http.HandleFunc("/panel", panel)
|
|
err := http.ListenAndServe(":9197", nil)
|
|
if err != nil {
|
|
log.Fatal("ListenAndServe: ", err)
|
|
}
|
|
|
|
}
|