main
This commit is contained in:
parent
00199743d3
commit
ffa09a9337
24
main.go
24
main.go
|
|
@ -9,8 +9,28 @@ func main() {
|
||||||
// c.JSON(200, gin.H{
|
// c.JSON(200, gin.H{
|
||||||
// "message": "pong",
|
// "message": "pong",
|
||||||
// })
|
// })
|
||||||
// c.HTML(200, "index.html", gin.H{})
|
c.HTML(200, "index.html", gin.H{})
|
||||||
c.String(200, "hello world", gin.H{})
|
// c.String(200, "hello world", gin.H{})
|
||||||
|
})
|
||||||
|
r.GET("/in", func(c *gin.Context) {
|
||||||
|
c.HTML(200, "data.html", gin.H{
|
||||||
|
"data": "vaefgood",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
r.GET("form", func(c *gin.Context) {
|
||||||
|
c.HTML(200, "form.html", gin.H{})
|
||||||
|
})
|
||||||
|
r.POST("post", func(c *gin.Context) {
|
||||||
|
uname := c.PostForm("username")
|
||||||
|
c.JSON(200, gin.H{
|
||||||
|
"result": "ok",
|
||||||
|
"uname": uname,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
r.GET("/user/:name", func(c *gin.Context) {
|
||||||
|
c.HTML(200, "name.html", gin.H{
|
||||||
|
"data": c.Param("name"),
|
||||||
|
})
|
||||||
})
|
})
|
||||||
r.Run() // listen and serve on 0.0.0.0:8080
|
r.Run() // listen and serve on 0.0.0.0:8080
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>真不错</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{{.data}}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Document</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form action="/post" method="POST">
|
||||||
|
<input type="text" name="username" id="">
|
||||||
|
<input type="submit" value="提交">
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>真不错</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
hello {{.data}}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Reference in New Issue