67 lines
1.2 KiB
Go
67 lines
1.2 KiB
Go
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
|
|
}
|
|
*/
|
|
readconfigfile()
|
|
return
|
|
http.HandleFunc("/", okHandler)
|
|
err := http.ListenAndServe(":80", nil)
|
|
if err != nil {
|
|
log.Println("Error starting server:", err)
|
|
}
|
|
}
|