1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-12-02 20:22:52 +00:00

better searching

This commit is contained in:
Laura
2025-08-14 03:53:14 +02:00
parent 8a790df2af
commit c740cd293d
14 changed files with 582 additions and 143 deletions

28
main.go
View File

@@ -1,13 +1,9 @@
package main
import (
"errors"
"net/http"
"os/exec"
"path/filepath"
"runtime"
"strings"
"time"
"github.com/coalaura/logger"
adapter "github.com/coalaura/logger/http"
@@ -46,17 +42,6 @@ func main() {
r.Get("/-/stats/{id}", HandleStats)
r.Post("/-/chat", HandleChat)
if !NoOpen {
time.AfterFunc(500*time.Millisecond, func() {
log.Info("Opening browser...")
err := open("http://localhost:3443/")
if err != nil {
log.WarningE(err)
}
})
}
log.Info("Listening at http://localhost:3443/")
http.ListenAndServe(":3443", r)
}
@@ -73,16 +58,3 @@ func cache(next http.Handler) http.Handler {
next.ServeHTTP(w, r)
})
}
func open(url string) error {
switch runtime.GOOS {
case "linux":
return exec.Command("xdg-open", url).Start()
case "windows":
return exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
return exec.Command("open", url).Start()
}
return errors.New("unsupported platform")
}