跳至主要内容

博文

目前显示的是标签为“server”的博文

go server shutdown gracefully

package main import ( "fmt" "html/template" "io" "net/http" "net/url" "os" ) type TData struct { Clipboard, Copy, Send, CbContent, Files string FileSlice                               []string ChooseFile, UploadButton                string } type MyHTTPHandler struct{} var ( mux = make(map[string]func(http.ResponseWriter, *http.Request)) ) func (*MyHTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { u, _ := url.Parse(r.RequestURI) if h, ok := mux[u.Path]; ok { h(w, r) return } http.NotFound(w, r) } func main() { mux["/"] = home mux["/send"] = send mux["/downloadFile"] = downloadFile mux["/uploadFile"] = uploadFile myhandler := MyHTTPHandler{} server := http.Server{Addr: ":4444", Handler: &myhandler} err := server.ListenAndServe() if err != nil { fmt.Println(err) } }

go fileserver

package main import ( "fmt" "net/http" ) func main() { http.Handle("/s/", http.StripPrefix("/s/",     http.FileServer(http.Dir("/home/steven/Downloads")))) err := http.ListenAndServe(":8090", nil) if err != nil { fmt.Println(err) } }

arch dns server

sudo pacman -S pdnsd vim /usr/share/doc/pdnsd/pdnsd.conf cp /usr/share/doc/pdnsd/pdnsd.conf /etc/ pdnsd