fixup! Add lite webpage
This commit is contained in:
parent
6a415ce878
commit
19292ec746
@ -0,0 +1,9 @@
|
|||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Allowance Planner 2000</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Allowance Planner 2000</h1>
|
||||||
|
<h2>Users</h2>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -578,6 +578,10 @@ func getHistory(c *gin.Context) {
|
|||||||
c.IndentedJSON(http.StatusOK, history)
|
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.
|
Initialises the database, and then starts the server.
|
||||||
If the context gets cancelled, the server is shutdown and the database is closed.
|
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
|
corsConfig.AllowAllOrigins = true
|
||||||
router.Use(cors.New(corsConfig))
|
router.Use(cors.New(corsConfig))
|
||||||
|
|
||||||
|
// Web endpoints
|
||||||
|
router.LoadHTMLFiles("lite.gohtml")
|
||||||
|
router.GET("/", renderLite)
|
||||||
|
// API endpoints
|
||||||
router.GET("/api/users", getUsers)
|
router.GET("/api/users", getUsers)
|
||||||
router.GET("/api/user/:userId", getUser)
|
router.GET("/api/user/:userId", getUser)
|
||||||
router.POST("/api/user/:userId/history", postHistory)
|
router.POST("/api/user/:userId/history", postHistory)
|
||||||
@ -641,7 +649,7 @@ func start(ctx context.Context, config *ServerConfig) {
|
|||||||
func main() {
|
func main() {
|
||||||
config := ServerConfig{
|
config := ServerConfig{
|
||||||
Datasource: os.Getenv("DB_PATH"),
|
Datasource: os.Getenv("DB_PATH"),
|
||||||
Addr: ":8080",
|
Addr: ":8081",
|
||||||
}
|
}
|
||||||
if config.Datasource == "" {
|
if config.Datasource == "" {
|
||||||
config.Datasource = "allowance_planner.db3"
|
config.Datasource = "allowance_planner.db3"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user