antony@notes:~/misc$ cat "Untitled-11.md"
Untitled
main.go
package main
import (
"fmt"
"net/http"
"net/http/cgi"
)
func cgiMyDB(w http.ResponseWriter, r *http.Request) {
handler := cgi.Handler{Path: "/opt/www/cgi/mydb.sh"}
handler.ServeHTTP(w, r)
}
func cgiMyData(w http.ResponseWriter, r *http.Request) {
handler := cgi.Handler{Path: "/opt/www/cgi/mydata.sh"}
handler.ServeHTTP(w, r)
}
func cgiSetup(w http.ResponseWriter, r *http.Request) {
handler := cgi.Handler{Path: "/opt/www/cgi/mysetup.sh"}
handler.ServeHTTP(w, r)
}
func main() {
static := http.FileServer(http.Dir("/opt/www"))
http.Handle("/",static)
http.HandleFunc("/db", cgiMyDB)
http.HandleFunc("/data", cgiMyData)
http.HandleFunc("/setup", cgiSetup)
fmt.Println(":8080")
http.ListenAndServe(":8080", nil)
}mydb.sh連線到 mysql Clustermydata.sh連線到 大數據mysetup.sh