Пример #1
0
func main() {
	os.Args[0] = "wax"
	flag.Usage = usage
	flag.BoolVar(&test, "t", false, "create some test parts")
	flag.BoolVar(&wax.Verbose, "v", false, "verbose")
	flag.StringVar(&port, "p", "9191", "port")
	flag.Parse()
	wax.Verbose = true
	ctl.Debug = true
	wax.ServeLogin("/", "/index")
	index.ServeAt("/index", testParts())
	if err := wax.Serve(":" + port); err != nil {
		dbg.Fatal("serve: %s", err)
	}
}
Пример #2
0
func zxwax() {
	ctrl := ctl.NewControl()
	ctrl.BoolFlag("Debug", &Debug)
	ctrl.CmdFlag("Exit", func() {
		dbg.Fatal("exiting at user request")
	})
	wax.ServeLogin("/", "/index")
	pg := `$tb$<p>$zx$<p>`
	part, err := wax.New(pg)
	if err != nil {
		dbg.Warn("wax new: %s", err)
		return
	}
	part.SetEnv(map[string]interface{}{
		"tb": ctrl.Bar("tb"),
		"zx": zxw,
	})
	part.Serve("/index")
	if err = wax.Serve(":" + wport); err != nil {
		dbg.Warn("wax serve: %s", err)
	}
}