Product creation
This commit is contained in:
1 parent
f3f1652890
commit
105bbd3e96
2 files changed
+36
-5
No files matched your search
@@ -1,4 +1,5 @@
|
||||
from flask import jsonify, abort, request
|
||||
from flask_jwt_extended import jwt_required, get_jwt_identity
|
||||
|
||||
from app.api import bp_product
|
||||
|
||||
@@ -29,7 +30,23 @@ def get_product_info(id: int):
|
||||
|
||||
return result, status_code
|
||||
|
||||
|
||||
|
||||
@bp_product.route('/create', methods=['POST'])
|
||||
@jwt_required()
|
||||
def create_product_listing():
|
||||
user_id = get_jwt_identity()
|
||||
name = request.json.get('name')
|
||||
|
||||
price = request.json.get('price')
|
||||
|
||||
if name is None or price is None:
|
||||
return abort(401)
|
||||
|
||||
float_price = float(price)
|
||||
|
||||
if not isinstance(float_price, float):
|
||||
return abort(401)
|
||||
|
||||
result, status_code = ProductService.create_listing(user_id, name, float_price)
|
||||
|
||||
return result, status_code
|
||||
Reference in new issue
Block a user