-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
35 lines (27 loc) · 700 Bytes
/
main.go
File metadata and controls
35 lines (27 loc) · 700 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
// Serve the main page
r.GET("/", func(c *gin.Context) {
c.HTML(http.StatusOK, "index.html", nil)
})
// Handle radio button selection
/*
r.POST("/popup", func(c *gin.Context) {
selectedOption := c.PostForm("option")
c.HTML(http.StatusOK, "popup.html", gin.H{
"Option": selectedOption,
})
})*/
r.GET("/popup", func(c *gin.Context) {
choice := c.Query("option")
c.HTML(http.StatusOK, "popup.html", gin.H{"Option": choice})
})
// Load HTML templates
r.LoadHTMLGlob("templates/*")
r.Run(":8090") // Run server on localhost:8080
}