Get website relative to executable

This commit is contained in:
Tracker-Friendly 2024-04-25 18:08:29 +01:00
parent 4753feeab9
commit a4851fa6d3
2 changed files with 6 additions and 1 deletions

Binary file not shown.

View File

@ -3,11 +3,16 @@ package main
import (
"github.com/arzumify/webview_go-4.1"
"net/http"
"os"
"path/filepath"
)
func main() {
go func() {
http.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir("./website"))))
exepath, _ := os.Executable()
path, _ := filepath.EvalSymlinks(exepath)
http.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir(filepath.Dir(path) + "/website"))))
http.ListenAndServe("localhost:52064", nil)
}()