basic status page, move config into data dir

This commit is contained in:
Carl Pearson
2024-10-17 05:44:41 -06:00
parent 57ba3767d1
commit 38689752bd
11 changed files with 130 additions and 65 deletions

17
handlers/footer.go Normal file
View File

@@ -0,0 +1,17 @@
package handlers
import "ytdlp-site/config"
type Footer struct {
BuildDate string
BuildId string
BuildIdShort string
}
func MakeFooter() Footer {
return Footer{
BuildDate: config.GetBuildDate(),
BuildId: config.GetGitSHA(),
BuildIdShort: config.GetGitSHA()[0:7],
}
}

28
handlers/status.go Normal file
View File

@@ -0,0 +1,28 @@
package handlers
import (
"net/http"
"github.com/labstack/echo/v4"
"ytdlp-site/ffmpeg"
"ytdlp-site/ytdlp"
)
func StatusGet(c echo.Context) error {
ytdlpStdout, _, err := ytdlp.Run("--version")
if err != nil {
log.Errorln(err)
}
ffmpegStdout, _, err := ffmpeg.Ffmpeg("-version")
if err != nil {
log.Errorln(err)
}
return c.Render(http.StatusOK, "status.html", map[string]interface{}{
"ytdlp": string(ytdlpStdout),
"ffmpeg": string(ffmpegStdout),
"Footer": MakeFooter(),
})
}