Skip to content

Commit

Permalink
fix: templates embed
Browse files Browse the repository at this point in the history
  • Loading branch information
krau committed Dec 3, 2024
1 parent 5a40438 commit 6fb8440
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package main

import (
_ "KemonoSearch/docs"
"embed"
"fmt"
"html/template"
"os"
"time"

Expand Down Expand Up @@ -34,6 +36,9 @@ type SearchResult struct {
var CreatorsFileUrl = "https://kemono.su/api/v1/creators.txt"
var db *gorm.DB

//go:embed web/templates/*
var FS embed.FS

func main() {
var err error
db, err = gorm.Open(gormlite.Open(GetDefaultEnv("KEMONOSEARCH_DB", "creators.db")))
Expand All @@ -57,7 +62,8 @@ func main() {
gin.SetMode(gin.ReleaseMode)
router := gin.Default()

router.LoadHTMLGlob("web/templates/*")
templ := template.Must(template.New("").ParseFS(FS, "web/templates/*.html"))
router.SetHTMLTemplate(templ)

router.GET("/", func(ctx *gin.Context) {
name := ctx.Query("name")
Expand Down

0 comments on commit 6fb8440

Please sign in to comment.