github.com/gogf/gf@v1.16.9/.example/net/ghttp/server/template/tpl2/main.go (about)

     1  package main
     2  
     3  import (
     4  	"github.com/gogf/gf/frame/g"
     5  	"github.com/gogf/gf/frame/gins"
     6  	"github.com/gogf/gf/net/ghttp"
     7  )
     8  
     9  func main() {
    10  	s := g.Server()
    11  	s.SetServerRoot("public")
    12  	s.SetNameToUriType(ghttp.URI_TYPE_ALLLOWER)
    13  	s.SetErrorLogEnabled(true)
    14  	s.SetAccessLogEnabled(true)
    15  	s.SetPort(2333)
    16  
    17  	s.BindHandler("/", func(r *ghttp.Request) {
    18  		content, _ := gins.View().Parse("test.html", nil)
    19  		r.Response.Write(content)
    20  	})
    21  
    22  	s.Run()
    23  }