Add support for database path from environment variable
All checks were successful
Build / build (push) Successful in 2m43s
Deploy / build (push) Successful in 3m57s

This commit is contained in:
2025-03-24 12:45:29 +01:00
parent d0af018510
commit 5df1e9485a

10
main.go
View File

@@ -5,6 +5,7 @@ import (
"html/template"
"log"
"net/http"
"os"
"gitea.seeseepuff.be/seeseemelk/mysqlite"
"github.com/gin-gonic/gin"
@@ -18,7 +19,14 @@ var templateFS embed.FS
func main() {
log.Println("Starting...")
db, err := mysqlite.OpenDb("pcinv.db3")
// Get database path from environment variable or use default
dbPath := os.Getenv("PCINV_DB")
if dbPath == "" {
dbPath = "pcinv.db3"
}
db, err := mysqlite.OpenDb(dbPath)
if err != nil {
log.Fatalf("error opening db: %v", err)
}