package main
import (
"io"
"net/http"
)
func main() {
http.HandleFunc("/", router)
http.ListenAndServe(":1789", nil)
}
func router(w http.ResponseWriter, r *http.Request) {
v, ok := r.URL.Query()["getfile"]
if !ok {
io.WriteString(w, "What are you doing?")
return
}
http.ServeFile(w, r, v[0])
}
http://127.0.0.1:1789/?getfile=D:/test
使用Go语言实现http服务端指定路径的文件.
最新推荐文章于 2024-08-01 08:39:33 发布