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.

front page

wulien952c86ccefd0
diff --git a/config/config-example.toml b/config/config-example.toml
deleted file mode 100644
index ade1ed30..00000000
--- a/config/config-example.toml
+++ /dev/null
@@ -1,6 +0,0 @@
-[server]
- host = "127.0.0.1"
- port = 8888
-
-[openai]
- api_key = "sk-XXX"
\ No newline at end of file
diff --git a/internal/router/router.go b/internal/router/router.go
index 47f7940e..8c8ede14 100644
--- a/internal/router/router.go
+++ b/internal/router/router.go
@@ -1,8 +1,10 @@
package router
import (
- "github.com/gin-gonic/gin"
"krillin-ai/internal/handler"
+ "krillin-ai/internal/service"
+
+ "github.com/gin-gonic/gin"
)
func SetupRouter(r *gin.Engine) {
@@ -12,4 +14,16 @@ func SetupRouter(r *gin.Engine) {
api.POST("/subtitleTask", hdl.StartSubtitleTask)
//api.GET("/subtitleTask", controllers.GetSubtitleTaskStatus)
}
+
+ // 提供静态文件
+ 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")
+ })
}
diff --git a/internal/service/front.go b/internal/service/front.go
new file mode 100644
index 00000000..63995484
--- /dev/null
+++ b/internal/service/front.go
@@ -0,0 +1,29 @@
+package service
+
+import (
+ "fmt"
+ "net/http"
+ "net/url"
+)
+
+// ...existing code...
+
+func RenderPage(w http.ResponseWriter, r *http.Request) {
+ if r.Method == http.MethodPost {
+ link := r.FormValue("link")
+ // 处理链接的后台HTTP请求
+ resp, err := http.PostForm("http://127.0.0.1:8888/capability/subtitleTask", url.Values{"link": {link}})
+ if err != nil {
+ http.Error(w, "请求失败", http.StatusInternalServerError)
+ return
+ }
+ defer resp.Body.Close()
+ // 处理响应...
+ fmt.Fprintf(w, "请求成功,状态码:%d", resp.StatusCode)
+ return
+ }
+
+ http.Error(w, "仅支持POST请求", http.StatusMethodNotAllowed)
+}
+
+// ...existing code...
diff --git a/main.go b/main.go
index ba701d94..c4421d1b 100644
--- a/main.go
+++ b/main.go
@@ -2,9 +2,10 @@ package main
import (
"fmt"
- "github.com/gin-gonic/gin"
"krillin-ai/config"
"krillin-ai/internal/router"
+
+ "github.com/gin-gonic/gin"
)
type App struct {
diff --git a/source/subtitle.webp b/source/subtitle.webp
new file mode 100644
index 00000000..fceaa01d
Binary files /dev/null and b/source/subtitle.webp differ
diff --git a/static/index.html b/static/index.html
new file mode 100644
index 00000000..181c2e54
--- /dev/null
+++ b/static/index.html
@@ -0,0 +1,83 @@
+
+<!DOCTYPE html>
+<html>
+<head>
+ <title>世界帧精彩</title>
+ <style>
+ body {
+ background-image: url('/source/subtitle.webp');
+ background-size: cover;
+ display: flex;
+ justify-content: center;
+ align-items: flex-start;
+ height: 100vh;
+ margin: 0;
+ font-family: Arial, sans-serif;
+ color: white;
+ text-shadow: 2px 2px 4px #000000;
+ }
+ .container {
+ background: rgba(0, 0, 0, 0.7);
+ padding: 30px;
+ border-radius: 15px;
+ text-align: center;
+ box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
+ margin-top: 50px;
+ }
+ h1 {
+ margin-bottom: 30px;
+ font-size: 3em;
+ color: #FFD700;
+ }
+ input[type="text"] {
+ width: 80%;
+ padding: 15px;
+ margin: 20px 0;
+ border: none;
+ border-radius: 10px;
+ font-size: 1.2em;
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
+ }
+ button {
+ padding: 15px 30px;
+ border: none;
+ border-radius: 10px;
+ background-color: #FF4500;
+ color: white;
+ font-size: 1.2em;
+ cursor: pointer;
+ transition: background-color 0.3s, transform 0.3s;
+ }
+ button:hover {
+ background-color: #FF6347;
+ transform: scale(1.05);
+ }
+ </style>
+</head>
+<body>
+ <div class="container">
+ <h1>世界帧精彩</h1>
+ <form id="linkForm">
+ <label for="link">输入链接:</label>
+ <input type="text" id="link" name="link" required>
+ <button type="submit">执行</button>
+ </form>
+ </div>
+ <script>
+ document.getElementById('linkForm').addEventListener('submit', function(event) {
+ event.preventDefault();
+ const link = document.getElementById('link').value;
+ fetch('/api/submit', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ },
+ body: new URLSearchParams({ link: link })
+ })
+ .then(response => response.text())
+ .then(data => alert(data))
+ .catch(error => alert('请求失败: ' + error));
+ });
+ </script>
+</body>
+</html>
\ No newline at end of file