一、简介
- 一个基于 FastAPI 和 Pillow 的 GitHub 仓库卡片生成工具,支持 Web 界面和 API 调用
- 可以自动获取、更新github开源仓库信息,包括作者头像,仓库贡献者、issues、Fork、Star数量等
- 动态渲染生成美观好看的信息卡片图片
- 支持 Docker 快速安装部署
- 项目代码地址参考:https://github.com/luler/hello_github_card
- 该工具的工作原理与架构图可参考下图
二、安装
- 准备一台主机,提前安装好Docker、docker-compose软件环境
- 新建docker-compose.yml配置文件,配置内容如下:
version: '3' services: github-card-generator: image: ghcr.io/luler/hello_github_card:latest restart: unless-stopped ports: - "8000:8000" volumes: # 持久化存储生成的图片 - ./images:/app/images
- 执行如下命令,快速启动程序
docker-compose up -d
成功启动,服务将运行在8000端口,参考下图
三、使用
-
安装启动之后,可以通过访问页面、调用API等方式生成 github 的仓库信息卡片
-
访问页面,在线使用,访问地址:http://server_ip:8000/ ,页面展示如下
-
调用实时生成github仓库信息卡片接口,参考如下
接口(POST):/api/generate 请求参数(json): { "repo_url": "https://github.com/luler/hello_github_card" //github仓库地址 } 返回(json): { "success": true, "message": "卡片生成成功", "data": { "owner": "microsoft", "repo_name": "vscode", "image_url": "/images/microsoft/vscode.png", //信息卡片图片 "filename": "vscode.png", "repo_info": { "description": "Visual Studio Code", //仓库描述 "stars": 177301, //Star数量 "forks": 35380, //Fork数量 "issues": 13887, //issue数量 "contributors": 329 //贡献者数量 } } }
-
直接渲染生成信息卡片接口(信息卡片自动缓存、自动更新,可以直接作为图片链接使用)
接口(GET):/github/{owner}/{repo_name} 请求参数(url参数): owner:仓库作者 repo_name:仓库名称 返回(binary): 信息卡片图片数据
请求示例参考下图
四、总结
- 这是个简易的小工具,可以帮助快速生成好看的开源github仓库信息卡片图片,可用于交流分享、开源导航
- 支持Docker快速部署,提供在线页面和API,使用起来非常方便,且易于集成
该工具的演示地址参考:https://cas.luler.top/?search=68de28ca84a3a
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容