fix: 添加 GET /api/categories/<id> 单个分类详情API

This commit is contained in:
2026-04-28 09:10:40 +08:00
parent 8066fc4386
commit 438fba347a
13 changed files with 28789 additions and 31 deletions

11
app.py
View File

@@ -951,6 +951,17 @@ def api_categories():
return jsonify(sorted(categories, key=lambda x: x.get('order', 0)))
@app.route('/api/categories/<category_id>')
def api_category_detail(category_id):
"""获取单个分类详情"""
categories = load_data(CATEGORIES_FILE)
category = next((c for c in categories if c['id'] == category_id), None)
if not category:
return jsonify({'error': 'Category not found'}), 404
return jsonify(category)
@app.route('/api/categories', methods=['POST'])
def api_create_category():
"""创建新分类"""