fix: 添加 GET /api/categories/<id> 单个分类详情API
This commit is contained in:
11
app.py
11
app.py
@@ -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():
|
||||
"""创建新分类"""
|
||||
|
||||
Reference in New Issue
Block a user