diff --git a/backend/lite.gohtml b/backend/lite.gohtml index e69de29..9bb9e0d 100644 --- a/backend/lite.gohtml +++ b/backend/lite.gohtml @@ -0,0 +1,9 @@ + + + Allowance Planner 2000 + + +

Allowance Planner 2000

+

Users

+ + diff --git a/backend/main.go b/backend/main.go index 49a8a0d..f496614 100644 --- a/backend/main.go +++ b/backend/main.go @@ -578,6 +578,10 @@ func getHistory(c *gin.Context) { c.IndentedJSON(http.StatusOK, history) } +func renderLite(c *gin.Context) { + c.HTML(http.StatusOK, "lite.gohtml", nil) +} + /* Initialises the database, and then starts the server. If the context gets cancelled, the server is shutdown and the database is closed. @@ -592,6 +596,10 @@ func start(ctx context.Context, config *ServerConfig) { corsConfig.AllowAllOrigins = true router.Use(cors.New(corsConfig)) + // Web endpoints + router.LoadHTMLFiles("lite.gohtml") + router.GET("/", renderLite) + // API endpoints router.GET("/api/users", getUsers) router.GET("/api/user/:userId", getUser) router.POST("/api/user/:userId/history", postHistory) @@ -641,7 +649,7 @@ func start(ctx context.Context, config *ServerConfig) { func main() { config := ServerConfig{ Datasource: os.Getenv("DB_PATH"), - Addr: ":8080", + Addr: ":8081", } if config.Datasource == "" { config.Datasource = "allowance_planner.db3"