From 0d5d357857e765f214ffd12979f77a385e59a19d Mon Sep 17 00:00:00 2001 From: John Date: Fri, 9 Nov 2018 17:48:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A8=A1=E6=9D=BF=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- geg/net/ghttp/server/template/tpl.go | 16 ------------- geg/net/ghttp/server/template/tpl1/index.html | 11 +++++++++ geg/net/ghttp/server/template/tpl1/tpl1.go | 23 +++++++++++++++++++ geg/other/test.go | 4 +++- 4 files changed, 37 insertions(+), 17 deletions(-) delete mode 100644 geg/net/ghttp/server/template/tpl.go create mode 100644 geg/net/ghttp/server/template/tpl1/index.html create mode 100644 geg/net/ghttp/server/template/tpl1/tpl1.go diff --git a/geg/net/ghttp/server/template/tpl.go b/geg/net/ghttp/server/template/tpl.go deleted file mode 100644 index 87be74714..000000000 --- a/geg/net/ghttp/server/template/tpl.go +++ /dev/null @@ -1,16 +0,0 @@ -package main - -import ( - "gitee.com/johng/gf/g" - "gitee.com/johng/gf/g/net/ghttp" -) - -func main() { - s := g.Server() - s.BindHandler("/", func(r *ghttp.Request){ - content :=`{{if (get "name")}} {{get "name"}} {{else}} NoName {{end}}` - r.Response.WriteTplContent(content, nil) - }) - s.SetPort(8199) - s.Run() -} \ No newline at end of file diff --git a/geg/net/ghttp/server/template/tpl1/index.html b/geg/net/ghttp/server/template/tpl1/index.html new file mode 100644 index 000000000..8a50061ce --- /dev/null +++ b/geg/net/ghttp/server/template/tpl1/index.html @@ -0,0 +1,11 @@ + + + + + {{.title}} + + +

姓名 : {{.name}}

+12311 + + \ No newline at end of file diff --git a/geg/net/ghttp/server/template/tpl1/tpl1.go b/geg/net/ghttp/server/template/tpl1/tpl1.go new file mode 100644 index 000000000..f47bef17d --- /dev/null +++ b/geg/net/ghttp/server/template/tpl1/tpl1.go @@ -0,0 +1,23 @@ +package main + +import ( + "gitee.com/johng/gf/g/frame/gmvc" + "gitee.com/johng/gf/g/net/ghttp" +) +type ControllerIndex struct { + gmvc.Controller +} +func (c *ControllerIndex) Info() { + c.View.Assign("title", "Go Frame 第一个网站") + c.View.Assigns(map[string]interface{}{ + "name" : "很开心1", + "score" : 100, + }) + c.View.Display("index.html") +} +func main() { + s := ghttp.GetServer() + s.BindController("/", new(ControllerIndex)) + s.SetPort(8199) + s.Run() +} diff --git a/geg/other/test.go b/geg/other/test.go index 16c5cabe5..f080414e3 100644 --- a/geg/other/test.go +++ b/geg/other/test.go @@ -1,5 +1,7 @@ package main +import "fmt" + func main() { - <- make(chan struct{}) + fmt.Print(1) } \ No newline at end of file