- 新增 ApiKey 模型,支持 API 密钥认证 - 添加 require_api_key 装饰器实现 API 认证 - 实现 5 个站点管理 API 接口 (GET/POST/PUT/DELETE) - 添加后台 API Key 管理界面 - 添加数据库迁移脚本 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
27 lines
555 B
Python
27 lines
555 B
Python
"""
|
|
API Keys 表迁移脚本
|
|
|
|
执行方式: python migrations/add_api_keys_table.py
|
|
"""
|
|
import os
|
|
import sys
|
|
|
|
# 添加项目根目录到路径
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
from app import create_app, db
|
|
from models import ApiKey
|
|
|
|
|
|
def create_api_keys_table():
|
|
"""创建 api_keys 表"""
|
|
app = create_app('development')
|
|
|
|
with app.app_context():
|
|
# 直接创建表
|
|
db.create_all()
|
|
print('api_keys 表创建成功')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
create_api_keys_table() |