Skip to content

FIXUAI/web2pic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Web2Pic

多模型 AI 图片生成平台,支持 GPT-Image、Grok 等模型,通过 OpenAI 兼容 API 调用。

单文件 Flask 应用,SQLite 存储,零外部服务依赖,适合个人或小团队自部署。

功能概览

  • 多模型支持:gpt-image-2、gpt-5.4、gpt-5.5、grok-imagine-image-lite
  • 用户系统:注册 / 登录,首个注册用户自动成为管理员
  • 钱包计费:按次扣费,管理员可充值
  • API 配置:每个用户独立配置各模型的 Base URL 和 API Key
  • 图片管理:生成历史、图片预览与下载
  • 管理后台:用户管理(禁用 / 重置密码 / 删除)、生成记录查看、在线升级
  • 响应式布局:手机端自适应

快速开始(本地)

git clone https://github.com/FIXUAI/web2pic.git
cd web2pic
pip install -r requirements.txt
python app.py

浏览器打开 http://localhost:25000,注册第一个账号即为管理员。

项目结构

web2pic/
├── app.py                 # 后端主程序
├── requirements.txt       # Python 依赖(flask, requests)
├── static/
│   ├── css/style.css      # 全局样式
│   ├── js/                # 各页面 JS
│   ├── index.html         # 工作台(生图)
│   ├── settings.html      # API 设置
│   ├── admin.html         # 管理后台
│   ├── login.html         # 登录
│   └── register.html      # 注册
└── data/                  # 运行时数据(自动创建,已 gitignore)
    ├── web2pic.db         # SQLite 数据库
    ├── savedpics/         # 生成的图片
    └── upgrade_packages/  # 升级包与备份

Debian 13 部署指南

以下以 Debian 13 (Trixie) 全新系统为例,使用 Gunicorn + Supervisor 部署。

1. 系统准备

sudo apt update && sudo apt upgrade -y
sudo apt install -y python3 python3-pip python3-venv git supervisor

2. 获取代码

cd /opt
sudo git clone https://github.com/FIXUAI/web2pic.git
sudo chown -R www-data:www-data /opt/web2pic

3. 创建虚拟环境

cd /opt/web2pic
sudo -u www-data python3 -m venv venv
sudo -u www-data venv/bin/pip install -r requirements.txt
sudo -u www-data venv/bin/pip install gunicorn

4. 配置 Supervisor

创建配置文件:

sudo tee /etc/supervisor/conf.d/web2pic.conf << 'EOF'
[program:web2pic]
command=/opt/web2pic/venv/bin/gunicorn -w 4 -b 0.0.0.0:25000 --timeout 300 app:app
directory=/opt/web2pic
user=www-data
autostart=true
autorestart=true
stdout_logfile=/var/log/web2pic.log
stderr_logfile=/var/log/web2pic_err.log
EOF

启动服务:

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start web2pic

5. 验证

curl -s http://localhost:25000/api/auth/me
# 应返回 {"user": null}

浏览器访问 http://你的服务器IP:25000,注册第一个账号即为管理员。

6. 反向代理(可选)

如需域名访问和 HTTPS,可配合 Nginx:

sudo apt install -y nginx
# /etc/nginx/sites-available/web2pic
server {
    listen 80;
    server_name your-domain.com;

    client_max_body_size 50m;

    location / {
        proxy_pass http://127.0.0.1:25000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_read_timeout 300s;
    }
}
sudo ln -s /etc/nginx/sites-available/web2pic /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx

HTTPS 推荐使用 Certbot

sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d your-domain.com

常用运维命令

# 查看服务状态
sudo supervisorctl status web2pic

# 重启服务
sudo supervisorctl restart web2pic

# 查看日志
tail -f /var/log/web2pic.log

# 备份数据库
cp /opt/web2pic/data/web2pic.db /opt/web2pic/data/web2pic.db.bak

更新日志

  • v1.2.0 — 账号管理、在线升级、响应式布局、修改密码
  • v1.1.0 — 初始版本

License

MIT

About

可以本地部署,提供demo网站快速体验,请务必使用测试 apikey 设置限额和自动过期,并及时删除。 用户可以为每个模型独立配置Base URL 和 API Key,只要是兼容 OpenAI 这两种接口格式的中转服务都能接入。 1. image-generation — 原生图像生成接口(/v1/images/generations),用于 gpt-image-2 2. chat-completion — Chat 对话接口(/v1/chat/completions),用于gpt-5.4、gpt-5.5、grok-imagine-image-lite API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors