2024-01-12 04:14:09 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
"embed"
|
|
|
|
)
|
|
|
|
|
|
|
|
//go:embed files/*
|
|
|
|
var htmlFiles embed.FS
|
|
|
|
|
|
|
|
func okHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
dumpClient(r)
|
|
|
|
var tmp string
|
|
|
|
tmp = r.URL.String()
|
|
|
|
if tmp == "/test" {
|
|
|
|
findFile(w)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if tmp == "/gui" {
|
|
|
|
doGui(w, "/gui/gui")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
fmt.Fprintln(w, "OK")
|
|
|
|
}
|
|
|
|
|
|
|
|
func findFile(w http.ResponseWriter) {
|
|
|
|
fmt.Fprintln(w, "GOT TEST?")
|
|
|
|
pfile, err := htmlFiles.ReadFile("files/repo.html")
|
|
|
|
if (err != nil) {
|
|
|
|
log.Println("ERROR: err")
|
|
|
|
// w.Write(pfile)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var repohtml string
|
|
|
|
repohtml = string(pfile)
|
|
|
|
fmt.Fprintln(w, "GOT GUI?", repohtml)
|
|
|
|
log.Println("repo.html:", repohtml)
|
|
|
|
// w.Close()
|
|
|
|
/*
|
|
|
|
filename = "/tmp/" + name + ".so"
|
|
|
|
log.Error(err, "write out file here", name, filename, len(pfile))
|
|
|
|
f, _ := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0600)
|
|
|
|
f.Close()
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
/*
|
|
|
|
pfile, err := htmlFiles.ReadFile("html/repo.html")
|
|
|
|
if (err != nil) {
|
|
|
|
log.Println("ERROR:", err)
|
|
|
|
// w.Write(pfile)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
*/
|
2024-01-12 04:44:36 -06:00
|
|
|
readconfigfile()
|
|
|
|
return
|
2024-01-12 04:14:09 -06:00
|
|
|
http.HandleFunc("/", okHandler)
|
|
|
|
err := http.ListenAndServe(":80", nil)
|
|
|
|
if err != nil {
|
|
|
|
log.Println("Error starting server:", err)
|
|
|
|
}
|
|
|
|
}
|