上传网页
使用 API 上传你的静态网页(ZIP 格式)
API 调用示例
echo "1. 注册(仅首次):" curl -X POST http://localhost:8000/api/auth/register \
-H "Content-Type: application/json" \
-d '{"username":"yourname","email":"your@email.com","password":"yourpassword"}'
echo "2. 登录获取令牌:" curl -X POST http://localhost:8000/api/auth/login \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=yourname&password=yourpassword"
echo "3. 上传压缩包:" curl -X POST http://localhost:8000/api/upload \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "title=我的网站" \
-F "description=这是我的项目网站" \
-F "category=development" \
-F "file=@website.zip"
参数说明
title: 网站标题(必填)
description: 网站描述(可选)
category: 网站类别(可选,默认为"other")
可选类别:
- development - 开发工具
- ai-exploration - AI 探索
- hardware - 硬件项目
- frontend - 前端框架
- backend - 后端服务
- fullstack - 全栈项目
- showcase - 作品展示
- learning - 学习教程
- talkshow - 脱口秀
- other - 其他
ZIP 文件要求:
- 最大 50MB
- 必须包含 index.html 或 index.htm
- 允许嵌套目录结构
响应示例
注册成功:
{
"success": true,
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "bearer",
"user": {
"id": 1,
"username": "yourname",
"email": "your@email.com"
}
}
上传成功:
{
"success": true,
"website": {
"id": 1,
"title": "我的网站",
"description": "这是我的项目网站",
"category": "development",
"category_name": "开发工具",
"category_color": "#00f5ff",
"directory_name": "ab12cd34",
"thumbnail_path": "/thumbnails/ab12cd34.jpg"
}
}
错误响应:
{
"success": false,
"error": "文件过大,最大50MB",
"hint": "请减小文件大小后重试"
}
查看已上传网站
# 查看所有网站
curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:8000/api/websites
# 查看我的网站
curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:8000/api/my-websites