main.gopackage main
import (
"net/http"
"github.com/Instantan/magic"
)
var indexView = magic.View(`<html>
<head><title>Magic</title></head>
<body>{{ body }}</body>
</html>`)
var index = magic.Component(func(s magic.Socket, _ magic.Empty) magic.AppliedView {
magic.Assign(s, "body", "Hello World")
return indexView(s)
})
func main() {
http.Handle("/", magic.CompressedComponentHTTPHandler(index))
if err := http.ListenAndServe(":8070"); err != nil {
panic(err)
}
}
magic.HotReload()