зеркало из https://github.com/softlandia/gin-s1.git
This commit is contained in:
Коммит
f57f70ccec
|
@ -0,0 +1,28 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
router := gin.Default()
|
||||
router.LoadHTMLGlob("templates/*")
|
||||
router.GET("/", func(c *gin.Context) {
|
||||
|
||||
// Call the HTML method of the Context to render a template
|
||||
c.HTML(
|
||||
// Set the HTTP status to 200 (OK)
|
||||
http.StatusOK,
|
||||
// Use the index.html template
|
||||
"index.html",
|
||||
// Pass the data that the page uses (in this case, 'title')
|
||||
gin.H{
|
||||
"title": "Home Page",
|
||||
},
|
||||
)
|
||||
|
||||
})
|
||||
router.Run()
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<!--footer.html-->
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -0,0 +1,19 @@
|
|||
<!--header.html-->
|
||||
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<!--Use the `title` variable to set the title of the page-->
|
||||
<title>{{ .title }}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta charset="UTF-8">
|
||||
|
||||
<!--Use bootstrap to make the application look nice-->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
|
||||
<script async src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
|
||||
<body class="container">
|
||||
<!--Embed the menu.html template at this location-->
|
||||
{{ template "menu.html" . }}
|
|
@ -0,0 +1,9 @@
|
|||
<!--index.html-->
|
||||
|
||||
<!--Embed the header.html template at this location-->
|
||||
{{ template "header.html" .}}
|
||||
|
||||
<h1>Hello Gin!</h1>
|
||||
|
||||
<!--Embed the footer.html template at this location-->
|
||||
{{ template "footer.html" .}}
|
|
@ -0,0 +1,11 @@
|
|||
<!--menu.html-->
|
||||
|
||||
<nav class="navbar navbar-default">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-brand" href="/">
|
||||
Home
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
Загрузка…
Ссылка в новой задаче