项目使用Go语言编写,支持vercel部署, 扩展可以使用vercel KV做缓存。 项目最初是为了解决img2color的API不稳定,所以自己重新写了一个。 前端访问 API 接口:https://example.com/api?imgUrl=图片地址 (示例)
例如: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 REDIS密码 USE_REDIS_CACHE bool值,是否启用REDIS REDIS_DB REDIS数据...
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 ...
2 changes: 1 addition & 1 deletion2vercel.json Original file line numberDiff line numberDiff line change Expand Up@@ -8,7 +8,7 @@ ], "routes": [ { "src":"/api/img2color", "src":"/api", "dest":"img2color" } ]
Img2color 本项目使用go作为基础,具有较高的性能 支持vercel与服务器部署 vercel部署 点击项目右上角fork叉子 登录vercel 在vercel导入项目 部署时添加环境变量 国内访问需绑定自定义域名 服务器部署 需要go环境 安装依赖 go mod tidy 运行 go run /api/img2color.go...
123 changes: 108 additions & 15 deletions 123 api/img2color.go Original file line numberDiff line numberDiff line change @@ -1,18 +1,111 @@ /* * @Description: * @Author: 安知鱼 * @Email: anzhiyu-c@qq.com * @Date: 2023-07-26 15:25:07 * @LastEditTime: 2023-07-26 16...
XingJi-love / img2color-go Public forked from anzhiyu-c/img2color-go Notifications Fork 0 Star 0 Commit Permalink 尝试部署vercel Browse files Loading branch information anzhiyu-c committed Jul 26, 2023 1 parent 5599340 commit c42073e Showing 1 changed file with 103 additions ...
main Breadcrumbs img2color-go / .env Latest commit HistoryHistory File metadata and controls Code Blame 9 lines (9 loc) · 240 Bytes Raw 1 2 3 4 5 6 7 8 9 REDIS_ADDRESS=${REDIS_ADDRESS} REDIS_PASSWORD=${REDIS_PASSWORD} USE_REDIS_CACHE=${USE_REDIS_CACHE} REDIS_DB=${REDIS_DB...
http.HandleFunc("/img2color", handleImageColor) func StartServer() { http.HandleFunc("/api", handleImageColor) port := os.Getenv("PORT") if port == "" { port = "3000" } fmt.Printf("服务器监听在:%s...\n", port) // Remove the extra period here fmt.Printf("服务器监听在:%s....
Binary file added BIN +8.44 MB img2color Binary file not shown. 107 changes: 107 additions & 0 deletions 107 img2color.go Original file line numberDiff line numberDiff line change @@ -0,0 +1,107 @@ package main import ( "encoding/json" "fmt" "image" "image/gif" "image/jpeg...