def create_product(): if request.method == 'POST': res = request.form p = Product(name=res['name'], description=res['description'], price=res['price']) p.save() return render_template('shop/create_product.html') return render_template('shop/create_product.html')
def create_product(): """ [POST] /api/shop """ response = request.get_json() product = Product() product.from_dict(response) db.session.add(product) db.session.commit() return jsonify(product.to_dict()), 201
def create_product(): data = request.json p = Product() p.from_dict(data) p.save() return jsonify(p.to_dict()), 201