项目使用Go语言编写,支持vercel部署, 扩展可以使用vercel KV做缓存。 项目最初是为了解决img2color的API不稳定,所以自己重新写了一个。 前端访问 API 接口:https://example.com/api?imgUrl=图片地址 (示例)
2 changes: 1 addition & 1 deletion 2 api/img2color.go Original file line numberDiff line numberDiff line change @@ -92,7 +92,7 @@ func handleImageColor(w http.ResponseWriter, r *http.Request) { } func Handler(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/", handle...
例如:https://img2color-go.vercel.app/api?img=https://npm.elemecdn.com/anzhiyu-blog@1.1.6/img/post/banner/神里.webp 部署后只需要 域名/api 访问 必填参数img: url .env文件配置说明
go run /api/img2color.go 此处不赘述守护进程。 使用 例如:https://img2color-go.vercel.app/api?img=https://npm.elemecdn.com/anzhiyu-blog@1.1.6/img/post/banner/神里.webp 部署后只需要 域名/api 访问 必填参数img: url .env文件配置说明 配置项说明 REDIS_ADDRESS REDIS地址 REDIS_PASSWORD RED...
go run /api/img2color.go 此处不赘述守护进程。 使用 例如:https://img2color-go.vercel.app/api?img=https://npm.elemecdn.com/anzhiyu-blog@1.1.6/img/post/banner/神里.webp 部署后只需要 域名/api 访问 必填参数img: url .env文件配置说明 ...
一个获取图片主色调GO API. Contribute to RedEyes04/img2color-go development by creating an account on GitHub.
http.HandleFunc("/api/img2color", handleImageColor) port := os.Getenv("PORT") if port == "" { port = "3000" } http.HandleFunc("/", Handler) fmt.Printf("服务器监听在:%s...\n", port) err := http.ListenAndServe(":"+port, nil) if err != nil { 15 changes: 0 additions ...
http.HandleFunc("api/img2color", handleImageColor) port := os.Getenv("PORT") 8 changes: 8 additions & 0 deletions 8 vercel.json Original file line numberDiff line numberDiff line change @@ -0,0 +1,8 @@ { "routes": [ { "src": "/api", "dest": "/api/img2color.go" } ...
一个获取图片主色调GO API. Contribute to XingJi-love/img2color-go development by creating an account on GitHub.
) // 假设"api"是根目录的子目录 // 获取当前工作目录的绝对路径 currentDir, err := os.Getwd() if err != nil { fmt.Printf("获取根目录路径时出错:%v\n", err) fmt.Printf("获取当前工作目录路径时出错:%v\n", err) return } envFile := filepath.Join(rootDir, ".env") // 构建 .env...