swag-shop/app/api/routes/product_routes.py

31 lines
713 B
Python

from flask import jsonify, abort, request
from app.api import bp_product
from app.services.product_service import ProductService
@bp_product.route('/get', methods=['GET'])
def get_products():
page = request.args.get('page', default=0, type=int)
if page < 0:
return abort(400)
result, status_code = ProductService.get_products(page)
return result, status_code
@bp_product.route('/<int:id>', methods=['GET'])
def get_product_info(id: int):
fields = ['name', 'price', 'image', 'image_name', 'seller']
fields_param = request.args.get('fields')
requested_fields = []
return abort(501)
@bp_product.route('/create', methods=['POST'])
def create_product_listing():
name = request.json.get('name')