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')
Example #2
0
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
Example #3
0
def create_product():
    data = request.json
    p = Product()
    p.from_dict(data)
    p.save()
    return jsonify(p.to_dict()), 201