mirror of
https://gitee.com/johng/gf.git
synced 2024-12-04 21:28:22 +08:00
40 lines
985 B
Go
40 lines
985 B
Go
package main
|
|
|
|
import (
|
|
"github.com/gogf/gf/g"
|
|
"github.com/gogf/gf/g/net/ghttp"
|
|
"github.com/gogf/gf/g/os/gview"
|
|
"github.com/gogf/gf/g/util/gpage"
|
|
)
|
|
|
|
func main() {
|
|
s := g.Server()
|
|
s.BindHandler("/:obj/*action/{page}.html", func(r *ghttp.Request) {
|
|
page := gpage.New(100, 10, r.Get("page"), r.URL.String(), r.Router)
|
|
buffer, _ := gview.ParseContent(`
|
|
<html>
|
|
<head>
|
|
<style>
|
|
a,span {padding:8px; font-size:16px;}
|
|
div{margin:5px 5px 20px 5px}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div>{{.page1}}</div>
|
|
<div>{{.page2}}</div>
|
|
<div>{{.page3}}</div>
|
|
<div>{{.page4}}</div>
|
|
</body>
|
|
</html>
|
|
`, g.Map{
|
|
"page1": page.GetContent(1),
|
|
"page2": page.GetContent(2),
|
|
"page3": page.GetContent(3),
|
|
"page4": page.GetContent(4),
|
|
})
|
|
r.Response.Write(buffer)
|
|
})
|
|
s.SetPort(8199)
|
|
s.Run()
|
|
}
|