kavea/src/main.go

44 lines
757 B
Go
Raw Normal View History

2021-05-28 16:19:18 -04:00
package main
import (
2021-09-19 18:40:50 -04:00
"embed"
2021-05-28 16:19:18 -04:00
"log"
"net/http"
"runtime"
"github.com/zserge/lorca"
)
2021-09-19 18:40:50 -04:00
//go:embed templates
var templatesHTML embed.FS
2021-05-28 16:19:18 -04:00
//go:embed static
var staticFiles embed.FS
func main() {
log.SetFlags(log.Lshortfile)
2021-09-19 18:40:50 -04:00
Test()
2021-05-28 16:19:18 -04:00
/* Web Server */
http.Handle("/static/", http.FileServer(http.FS(staticFiles)))
2021-09-19 16:45:21 -04:00
http.HandleFunc("/", GetHome) // Redirects to /search if auth'd
2021-05-28 16:19:18 -04:00
2021-09-19 16:45:21 -04:00
/* Start Web Server */
2021-05-28 16:19:18 -04:00
go func() {
2021-09-19 16:45:21 -04:00
log.Println("Server is running!")
2021-05-28 16:19:18 -04:00
log.Fatal(http.ListenAndServe(":3000", nil))
}()
/* GUI */
args := []string{}
if runtime.GOOS == "linux" {
args = append(args, "--class=Lorca")
}
ui, err := lorca.New("http://localhost:3000", "", 1000, 800, args...)
if err != nil {
log.Fatal(err)
}
defer ui.Close()
<-ui.Done()
}