web.go 475 B

1234567891011121314151617181920212223
  1. package main
  2. import (
  3. "log"
  4. "net/http"
  5. )
  6. func webServer(Dir string, tmpDir string, Port string) {
  7. fs := http.FileServer(http.Dir(Dir))
  8. http.Handle("/", fs)
  9. http.Handle("/output/", http.StripPrefix("/output/", http.FileServer(http.Dir(tmpDir))))
  10. //SYSTEM FUNCTION
  11. http.HandleFunc("/sendcommand", SendCommand)
  12. http.HandleFunc("/log", ReadLog)
  13. http.HandleFunc("/log/from", ReadLogFrom)
  14. err := http.ListenAndServe(Port, nil)
  15. if err != nil {
  16. log.Fatal(err)
  17. }
  18. }