2024-01-20 01:27:10 +02:00
|
|
|
package web
|
|
|
|
|
2024-01-20 01:40:55 +02:00
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"tea.chunkbyte.com/kato/drive-health/lib/hardware"
|
|
|
|
)
|
2024-01-20 01:27:10 +02:00
|
|
|
|
|
|
|
func setupFrontend(r *gin.Engine) {
|
2024-01-20 01:40:55 +02:00
|
|
|
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)
|
|
|
|
}
|
2024-01-20 01:27:10 +02:00
|
|
|
|
2024-01-20 01:40:55 +02:00
|
|
|
// Render the HTML template
|
|
|
|
c.HTML(http.StatusOK, "index.html", gin.H{
|
|
|
|
"drives": hardDrives,
|
|
|
|
})
|
|
|
|
})
|
2024-01-20 01:27:10 +02:00
|
|
|
}
|