-
-
Save metajiji/d0d75ac5ae215087cd2f91ad58a6e36a to your computer and use it in GitHub Desktop.
go htpp srv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"strings" | |
//"log" | |
) | |
func HomeRouterHandler(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, "")) | |
} | |
fmt.Fprintf(w, "Hello 123") | |
} | |
func main() { | |
http.HandleFunc("/", HomeRouterHandler) | |
fs := http.FileServer(http.Dir("static/")) | |
http.Handle("/static/", http.StripPrefix("/static/", fs)) | |
err := http.ListenAndServe(":9000", nil) | |
if err != nil { | |
//log.Fatal("ListenAndServe: ", err) | |
fmt.Println("ListenAndServe: ", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment