Post Reqeust via HTML FORM GinGonic golang framework 11
Post Reqeust via HTML FORM GinGonic golang framework 11
Source Code
// POST Request via HTML Form package main import "github.com/gin-gonic/gin" func main() { // create new router/server r := gin.Default() // register root folder for HTML Form file r.Static("/", "./") // post request r.POST("/post", func(c *gin.Context) { name := c.PostForm("name") // is the name of field // send back data received or show success c.String(200, "Hi %s", name) // lets create html form }) r.Run() }
Source Code – Index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>HTML POST REQ FORM</title> </head> <body> <form action="/post" method="post"> <input type="text" name="name" id=""> <button type="submit">submit</button> </form> </body> </html>
golang gingonic framework videos tutorials series
TAGS#
gin gonic tutorial
gin-gonic / examples
gin-gonic documentation
gin framework tutorial
gin web framework
gin router
golang gin context
gin router group