A website written in Go using WebAssembly and Vugu that converts strings to and from various encodings.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.1 KiB

// +build !wasm
package main
import (
"flag"
"log"
"net/http"
"os"
"path/filepath"
"github.com/vugu/vugu/devutil"
)
func main() {
dev := flag.Bool("dev", false, "Enable development features")
dir := flag.String("dir", ".", "Project directory")
httpl := flag.String("addr", ":8844", "Listen for HTTP on this host:port")
flag.Parse()
wd, _ := filepath.Abs(*dir)
os.Chdir(wd)
mux := devutil.NewMux()
mux.Match(devutil.NoFileExt, devutil.DefaultIndex.Replace(
`<!-- styles -->`,
`<link rel="stylesheet" href="/css/bulma.min.css">`,
).Replace(
`<!-- scripts -->`,
`<script src="/js/iconify.min.js"></script>`,
).Replace(
`<title>Vugu App</title>`,
`<title>WasmConv</title>`,
))
mux.Default(devutil.NewFileServer().SetDir("."))
if *dev {
wc := devutil.NewWasmCompiler().SetDir(".")
mux.Exact("/main.wasm", devutil.NewMainWasmHandler(wc))
mux.Exact("/wasm_exec.js", devutil.NewWasmExecJSHandler(wc))
log.Printf("Starting HTTP Server at %q", *httpl)
log.Fatal(http.ListenAndServe(*httpl, mux))
} else {
log.Printf("Starting HTTP Server at %q", *httpl)
log.Fatal(http.ListenAndServe(*httpl, mux))
}
}