fix(API): Restrict Blueprints
This commit is contained in:
1 parent
9f945884da
commit
39cc73d71a
2 files changed
+6
-6
No files matched your search
+2
-2
@@ -5,7 +5,7 @@ from flask import Blueprint
|
|||||||
# Создаем blueprint для API
|
# Создаем blueprint для API
|
||||||
api_category = Blueprint('api_category', __name__, url_prefix='/api/categories')
|
api_category = Blueprint('api_category', __name__, url_prefix='/api/categories')
|
||||||
|
|
||||||
@api_category.route('/categories', methods=['GET'])
|
@api_category.route('/', methods=['GET'])
|
||||||
def get_categories():
|
def get_categories():
|
||||||
"""
|
"""
|
||||||
Получение всех категорий с атрибутами
|
Получение всех категорий с атрибутами
|
||||||
@@ -17,7 +17,7 @@ def get_categories():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({"error": str(e)}), 500
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
@api_category.route('/categories/<int:category_id>', methods=['GET'])
|
@api_category.route('/<int:category_id>', methods=['GET'])
|
||||||
def get_category(category_id):
|
def get_category(category_id):
|
||||||
"""
|
"""
|
||||||
Получение категории по ID
|
Получение категории по ID
|
||||||
|
|||||||
+4
-4
@@ -3,9 +3,9 @@ from db.handlers.product_handler import get_products_with_filters, get_product_b
|
|||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
|
|
||||||
# Создаем blueprint для API
|
# Создаем blueprint для API
|
||||||
api_product = Blueprint('api_product', __name__, url_prefix='/api')
|
api_product = Blueprint('api_product', __name__, url_prefix='/api/products')
|
||||||
|
|
||||||
@api_product.route('/products', methods=['GET'])
|
@api_product.route('/', methods=['GET'])
|
||||||
def get_products():
|
def get_products():
|
||||||
"""
|
"""
|
||||||
Получение товаров с фильтрацией и пагинацией
|
Получение товаров с фильтрацией и пагинацией
|
||||||
@@ -51,7 +51,7 @@ def get_products():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({"error": str(e)}), 500
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
@api_product.route('/products/<int:product_id>', methods=['GET'])
|
@api_product.route('/<int:product_id>', methods=['GET'])
|
||||||
def get_product(product_id):
|
def get_product(product_id):
|
||||||
"""
|
"""
|
||||||
Получение товара по ID
|
Получение товара по ID
|
||||||
@@ -65,7 +65,7 @@ def get_product(product_id):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({"error": str(e)}), 500
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
@api_product.route('/products/fetchById', methods=['GET'])
|
@api_product.route('/fetchById', methods=['GET'])
|
||||||
def get_product_by_id_param():
|
def get_product_by_id_param():
|
||||||
"""
|
"""
|
||||||
Альтернативный маршрут для получения товара через query параметр
|
Альтернативный маршрут для получения товара через query параметр
|
||||||
|
|||||||
Reference in new issue
Block a user