web 服务

package main
import (
    "strings"
    "fmt"
    "net/http"
    "log"
)
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, " "))
    }
    fmt.Fprintf(w, "你好go")
}

func Start(){
    http.HandleFunc("/", sayHelloName)
    err := http.ListenAndServe(":9191", nil)
    if err != nil{
        log.Fatal("ListenAndServe: ", err)
    }
}
func main(){
    Start()
}

  

 

package main
import (
    "strings"
    "fmt"
    "net/http"
    "log"
)
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, " "))
    }
    fmt.Fprintf(w, "你好go")
}

func Start(){
    http.HandleFunc("/", sayHelloName)
    err := http.ListenAndServe(":9191", nil)
    if err != nil{
        log.Fatal("ListenAndServe: ", err)
    }
}
func main(){
    Start()
}


posted @ 2019-12-19 16:15  往事随风_go  阅读(235)  评论(0编辑  收藏  举报