pixivfe/main.go

41 lines
650 B
Go
Raw Normal View History

2023-05-13 03:34:31 +00:00
package main
import (
2023-05-13 12:25:32 +00:00
"html/template"
2023-05-18 13:18:44 +00:00
"pixivfe/configs"
2023-05-16 12:35:39 +00:00
"pixivfe/views"
2023-05-13 03:34:31 +00:00
"github.com/gin-gonic/gin"
)
2023-05-16 12:35:39 +00:00
func setupRouter() *gin.Engine {
server := gin.Default()
2023-05-16 12:35:39 +00:00
// For rankings to increment a number by 1
2023-05-13 12:25:32 +00:00
server.SetFuncMap(template.FuncMap{
2023-05-16 12:35:39 +00:00
"inc": func(n int) int {
return n + 1
},
2023-05-13 12:25:32 +00:00
})
2023-05-16 12:35:39 +00:00
// Static files
2023-05-14 12:30:03 +00:00
server.StaticFile("/favicon.ico", "./template/favicon.ico")
server.Static("css/", "./template/css")
2023-05-16 12:35:39 +00:00
// HTML templates, automatically loaded
server.LoadHTMLGlob("template/*.html")
2023-05-16 12:35:39 +00:00
// Routes/Views
views.SetupRoutes(server)
return server
}
func main() {
2023-05-18 13:18:44 +00:00
configs.Configs.ReadConfig()
2023-05-16 12:35:39 +00:00
r := setupRouter()
r.Run(":8080")
2023-05-13 03:34:31 +00:00
}