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 15:52:29 +01:00
|
|
|
func sayhelloName(w http.ResponseWriter, r *http.Request) {
|
|
|
|
r.ParseForm() // analizuj argumenty, musisz to sam wywołać
|
|
|
|
fmt.Println(r.Form) // drukuj informacje formularzy po stronie serwera
|
|
|
|
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-10 15:52:29 +01:00
|
|
|
fmt.Fprintf(w, "Cześć!") // wyślij dane na strone
|
2018-11-21 23:47:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2018-12-10 15:52:29 +01:00
|
|
|
http.HandleFunc("/", sayhelloName) // ustaw router
|
|
|
|
err := http.ListenAndServe(":8080", nil) // ustaw port nasłuchiwania
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal("ListenAndServe: ", err)
|
|
|
|
}
|
2018-11-21 23:47:31 +01:00
|
|
|
}
|