feat(api): Add new endpoit with documentation
https://git.rustprogersteam.ru/PVHProject/PVHFrontend/src/branch/main/README.md
This commit is contained in:
1 parent
78c5fc39b0
commit
ba81b2cf32
1 file changed
+24
@@ -9,6 +9,8 @@ from api.product import api_product
|
||||
from api.email import api_email
|
||||
from api.assets import assets_bp
|
||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||
from db.handlers.product_handler import get_product_list
|
||||
from flask import jsonify, request
|
||||
|
||||
# Инициализация
|
||||
initializeENV()
|
||||
@@ -27,6 +29,28 @@ app.register_blueprint(assets_bp)
|
||||
|
||||
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
|
||||
|
||||
@app.route('/productList', methods=['GET'], strict_slashes=False)
|
||||
def product_list():
|
||||
"""
|
||||
GET /api/productList/
|
||||
Получение списка товаров (без обязательных параметров)
|
||||
Query params: ?page=1&limit=20&categoryId=2 (все опциональны)
|
||||
"""
|
||||
try:
|
||||
page = request.args.get('page', 1, type=int)
|
||||
limit = request.args.get('limit', 100, type=int)
|
||||
category_id = request.args.get('categoryId', type=int)
|
||||
|
||||
if page < 1:
|
||||
page = 1
|
||||
if limit < 1 or limit > 200:
|
||||
limit = 100
|
||||
|
||||
products = get_product_list(page, limit, category_id)
|
||||
return jsonify(products), 200
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@app.route('/health', methods=['GET'])
|
||||
def health_check():
|
||||
"""Проверка работоспособности API"""
|
||||
|
||||
Reference in new issue
Block a user