fix(api): fix http respons and bad way
This commit is contained in:
1 parent
13fcc233ff
commit
0dc9034f19
4 files changed
+9
-6
No files matched your search
+2
-2
@@ -5,7 +5,7 @@ from flask import Blueprint
|
||||
# Создаем blueprint для API
|
||||
api_category = Blueprint('api_category', __name__, url_prefix='/categories')
|
||||
|
||||
@api_category.route('/', methods=['GET'])
|
||||
@api_category.route('/', methods=['GET'], strict_slashes=False)
|
||||
def get_categories():
|
||||
"""
|
||||
Получение всех категорий с атрибутами
|
||||
@@ -17,7 +17,7 @@ def get_categories():
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@api_category.route('/<int:category_id>', methods=['GET'])
|
||||
@api_category.route('/<int:category_id>', methods=['GET'], strict_slashes=False)
|
||||
def get_category(category_id):
|
||||
"""
|
||||
Получение категории по ID
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ from flask import Blueprint
|
||||
# Создаем blueprint для API
|
||||
api_email = Blueprint('api_email', __name__, url_prefix='/email')
|
||||
|
||||
@api_email.route('/', methods=['POST'])
|
||||
@api_email.route('/', methods=['POST'], strict_slashes=False)
|
||||
def post_email():
|
||||
if not request.is_json:
|
||||
return jsonify({"error": "Content-Type must be application/json"}), 400
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@ from flask import Blueprint
|
||||
# Создаем blueprint для API
|
||||
api_product = Blueprint('api_product', __name__, url_prefix='/products')
|
||||
|
||||
@api_product.route('/', methods=['GET'])
|
||||
@api_product.route('/', methods=['GET'], strict_slashes=False)
|
||||
def get_products():
|
||||
"""
|
||||
Получение товаров с фильтрацией и пагинацией
|
||||
@@ -51,7 +51,7 @@ def get_products():
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@api_product.route('/<int:product_id>', methods=['GET'])
|
||||
@api_product.route('/<int:product_id>', methods=['GET'], strict_slashes=False)
|
||||
def get_product(product_id):
|
||||
"""
|
||||
Получение товара по ID
|
||||
@@ -65,7 +65,7 @@ def get_product(product_id):
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@api_product.route('/fetchById', methods=['GET'])
|
||||
@api_product.route('/fetchById', methods=['GET'], strict_slashes=False)
|
||||
def get_product_by_id_param():
|
||||
"""
|
||||
Альтернативный маршрут для получения товара через query параметр
|
||||
|
||||
@@ -7,6 +7,7 @@ from utils.loadDotENV import initializeENV
|
||||
from api.categories import api_category
|
||||
from api.product import api_product
|
||||
from api.email import api_email
|
||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||
|
||||
# Инициализация
|
||||
initializeENV()
|
||||
@@ -22,6 +23,8 @@ app.register_blueprint(api_category)
|
||||
app.register_blueprint(api_product)
|
||||
app.register_blueprint(api_email)
|
||||
|
||||
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
|
||||
|
||||
@app.route('/health', methods=['GET'])
|
||||
def health_check():
|
||||
"""Проверка работоспособности API"""
|
||||
|
||||
Reference in new issue
Block a user