Skip to content

Instantly share code, notes, and snippets.

/web.go Secret

Created February 28, 2016 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/9b17f3f37a6efaa0c482 to your computer and use it in GitHub Desktop.
Save anonymous/9b17f3f37a6efaa0c482 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/gin-gonic/gin"
"net/http"
"os"
)
type Perso struct {
ID string
FirstName string
LastName string
}
func main() {
bind := fmt.Sprintf("%s:%s", os.Getenv("OPENSHIFT_GO_IP"), os.Getenv("OPENSHIFT_GO_PORT"))
gin.SetMode(gin.ReleaseMode)
router := gin.Default()
router.StaticFile("/favicon.ico", "./templates/favicon.ico")
router.StaticFile("/bootstrap.min.css", "./templates/bootstrap.min.css")
router.StaticFile("/bootstrap.min.js", "./templates/bootstrap.min.js")
//router.LoadHTMLGlob("templates/*")
router.LoadHTMLFiles("templates/index.html", "templates/id.html")
router.GET("/", func(c *gin.Context) {
c.HTML(http.StatusOK, "index.html", gin.H{
"title": "Main website",
"text": "this is text",
})
})
router.GET("/id/:id", func(c *gin.Context) {
Person := Perso{}
Person.ID = c.Param("id")
Person.FirstName = "Вася"
Person.LastName = "Пупкин"
c.HTML(http.StatusOK, "id.html", gin.H{
"title": Person.ID,
"firstname": Person.FirstName,
"lastname": Person.LastName,
"id": Person.ID,
})
})
router.Run(bind)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment