2018-11-21 23:47:31 +01:00
|
|
|
package main
|
2018-11-20 22:17:07 +01:00
|
|
|
|
2018-12-10 15:52:29 +01:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"html/template"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
"strings"
|
|
|
|
)
|
2018-11-21 23:47:31 +01:00
|
|
|
|
2018-12-10 18:00:33 +01:00
|
|
|
func sayhelloName(w http.ResponseWriter, r *http.Request) {
|
|
|
|
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, ""))
|
2018-11-21 23:47:31 +01:00
|
|
|
}
|
2018-12-17 22:35:22 +01:00
|
|
|
fmt.Fprintf(w, "Witaj, aby przejść do panelu logowania przejdź odpowiednio do Login!")
|
2018-12-17 22:59:32 +01:00
|
|
|
fmt.Fprintf(w, "/login")
|
2018-12-10 16:09:22 +01:00
|
|
|
}
|
|
|
|
|
2018-12-10 18:00:33 +01:00
|
|
|
func login(w http.ResponseWriter, r *http.Request) {
|
|
|
|
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"])
|
|
|
|
}
|
2018-11-21 23:47:31 +01:00
|
|
|
}
|
|
|
|
|
2018-12-17 22:35:22 +01:00
|
|
|
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"])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-21 23:47:31 +01:00
|
|
|
func main() {
|
2018-12-10 18:00:33 +01:00
|
|
|
http.HandleFunc("/", sayhelloName)
|
|
|
|
http.HandleFunc("/login", login)
|
2018-12-17 22:35:22 +01:00
|
|
|
http.HandleFunc("/panel", panel)
|
2018-12-10 18:00:33 +01:00
|
|
|
err := http.ListenAndServe(":9197", nil)
|
2018-12-10 15:52:29 +01:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal("ListenAndServe: ", err)
|
|
|
|
}
|
2018-12-10 18:00:33 +01:00
|
|
|
|
2018-11-21 23:47:31 +01:00
|
|
|
}
|