2018-04-22 22:17:20 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-07-29 21:01:19 +08:00
|
|
|
"github.com/gogf/gf/frame/g"
|
|
|
|
"github.com/gogf/gf/net/ghttp"
|
|
|
|
"github.com/gogf/gf/os/gview"
|
2018-04-22 22:17:20 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2020-03-21 23:13:31 +08:00
|
|
|
s := g.Server()
|
2019-04-03 00:03:46 +08:00
|
|
|
s.BindHandler("/page/demo", func(r *ghttp.Request) {
|
2020-03-06 11:01:03 +08:00
|
|
|
page := r.GetPage(100, 10)
|
2019-04-03 00:03:46 +08:00
|
|
|
buffer, _ := gview.ParseContent(`
|
2018-04-22 22:17:20 +08:00
|
|
|
<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{
|
2019-04-03 00:03:46 +08:00
|
|
|
"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()
|
|
|
|
}
|