/
server.go
executable file
·56 lines (38 loc) · 1.18 KB
/
server.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/contrib/static"
"net/http"
)
func main(){
router := gin.Default()
router.Use(static.Serve("/", static.LocalFile("webfiles", false)))
router.LoadHTMLGlob("webfiles/*.html")
// set up a redirect for /
router.GET("/", func (c *gin.Context) {
c.Redirect(http.StatusMovedPermanently, "/home")
})
router.GET("/home", func(c *gin.Context) {
c.HTML(http.StatusOK, "home.html", nil)
})
router.GET("/resume", func(c *gin.Context) {
c.HTML(http.StatusOK, "resume.html", nil)
})
router.GET("/projects", func(c *gin.Context) {
c.HTML(http.StatusOK, "projects.html", nil)
})
router.GET("/login", func(c *gin.Context) {
c.HTML(http.StatusOK, "login.html", nil)
})
router.POST("/login", func(c *gin.Context) {
Username := c.PostForm("Username")
Password := c.PostForm("Password")
fmt.Printf("Username: %s, Password: %s is logged in",
Username, Password)
})
router.GET("/ping", func(c *gin.Context) {
c.String(200, "test")
})
router.Run(":8000")
}