mirror of
https://github.com/JustKato/drive-health.git
synced 2026-02-27 06:17:00 +02:00
Api and Frontend
+ Snapshot get API + Frontend Starting
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"tea.chunkbyte.com/kato/drive-health/lib/hardware"
|
||||
"tea.chunkbyte.com/kato/drive-health/lib/svc"
|
||||
)
|
||||
|
||||
func setupApi(r *gin.Engine) {
|
||||
@@ -31,4 +32,10 @@ func setupApi(r *gin.Engine) {
|
||||
})
|
||||
})
|
||||
|
||||
api.GET("/snapshots", func(ctx *gin.Context) {
|
||||
snapshots := svc.GetHardwareSnapshot()
|
||||
|
||||
ctx.JSON(http.StatusOK, snapshots)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,31 @@
|
||||
package web
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"tea.chunkbyte.com/kato/drive-health/lib/hardware"
|
||||
)
|
||||
|
||||
func setupFrontend(r *gin.Engine) {
|
||||
r.LoadHTMLGlob("templates/*")
|
||||
r.Static("/static", "./static")
|
||||
|
||||
// Set up a route for the root URL
|
||||
r.GET("/", func(c *gin.Context) {
|
||||
|
||||
hardDrives, err := hardware.GetSystemHardDrives()
|
||||
if err != nil {
|
||||
c.AbortWithStatus(500)
|
||||
}
|
||||
|
||||
for _, hdd := range hardDrives {
|
||||
hdd.GetTemperature(true)
|
||||
}
|
||||
|
||||
// Render the HTML template
|
||||
c.HTML(http.StatusOK, "index.html", gin.H{
|
||||
"drives": hardDrives,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user