Skip to content

Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.

Embed static files

沈浩cb70befdba55
diff --git a/internal/router/router.go b/internal/router/router.go
index 62052299..841d6987 100644
--- a/internal/router/router.go
+++ b/internal/router/router.go
@@ -1,30 +1,24 @@
package router
import (
- "krillin-ai/internal/handler"
- "krillin-ai/internal/service"
-
"github.com/gin-gonic/gin"
+ "krillin-ai/internal/handler"
+ "krillin-ai/static"
+ "net/http"
)
func SetupRouter(r *gin.Engine) {
- api := r.Group("/capability")
+ api := r.Group("/api")
+
hdl := handler.NewHandler()
{
- api.POST("/subtitleTask", hdl.StartSubtitleTask)
- api.GET("/subtitleTask", hdl.GetSubtitleTask)
+ api.POST("/capability/subtitleTask", hdl.StartSubtitleTask)
+ api.GET("/capability//subtitleTask", hdl.GetSubtitleTask)
api.POST("/file", hdl.UploadFile)
}
- // 提供静态文件
- r.Static("/source", "./source")
- r.Static("/static", "./static")
-
- // 添加 API 路由
- r.POST("/api/submit", gin.WrapF(service.RenderPage))
-
- // 添加根路由
r.GET("/", func(c *gin.Context) {
- c.File("./static/index.html")
+ c.Redirect(http.StatusMovedPermanently, "/static")
})
+ r.StaticFS("/static", http.FS(static.EmbeddedFiles))
}
diff --git a/source/background.jpg b/static/background.jpg
similarity index 100%
rename from source/background.jpg
rename to static/background.jpg
diff --git a/static/embed.go b/static/embed.go
new file mode 100644
index 00000000..3fd21d81
--- /dev/null
+++ b/static/embed.go
@@ -0,0 +1,6 @@
+package static
+
+import "embed"
+
+//go:embed index.html background.jpg
+var EmbeddedFiles embed.FS
diff --git a/static/index.html b/static/index.html
index c5da8709..bf93db89 100644
--- a/static/index.html
+++ b/static/index.html
@@ -12,7 +12,7 @@
min-width: 320px;
min-height: 100vh;
color: #333;
- background: url('/source/background.jpg') no-repeat center center fixed;
+ background: url('/static/background.jpg') no-repeat center center fixed;
background-size: cover;
}
@@ -189,8 +189,8 @@
const progressBar = document.getElementById('progressBar');
const downloadLinks = document.getElementById('downloadLinks');
- const API_SUBMIT_URL = "/capability/subtitleTask";
- const API_PROGRESS_URL = "/capability/subtitleTask";
+ const API_SUBMIT_URL = "/api/capability/subtitleTask";
+ const API_PROGRESS_URL = "/api/capability/subtitleTask";
const API_UPLOAD_URL = "/api/upload";
let uploadedVideoUrl = null; // 存储上传后的视频地址