github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/utils/wasmserver/main.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"net/http"
     6  	"os"
     7  )
     8  
     9  const (
    10  	projectPath = "github.com/lmorg/murex/"
    11  	wasmPath    = "gen/website/wasm/"
    12  )
    13  
    14  func main() {
    15  	path := pathBuilder()
    16  
    17  	fmt.Println("Listening on :8080....")
    18  	fmt.Printf("Serving: %s....\n", path)
    19  	fmt.Printf("(press ^c to exit)")
    20  
    21  	err := http.ListenAndServe(":8080", http.FileServer(http.Dir(path)))
    22  	if err != nil {
    23  		fmt.Println("Failed to start server", err)
    24  		return
    25  	}
    26  }
    27  
    28  func goPath() string {
    29  	return os.Getenv("GOPATH")
    30  }
    31  
    32  func pathBuilder() string {
    33  	return goPath() + "/src/" + projectPath + wasmPath
    34  }