Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
562 B
2
Indexable
Never
@app.route('/products', methods=['GET', 'POST'])
def products():
    if request.method == 'POST':
        item_id = request.form["item_id"]
        row = db.cart.get("item_id", item_id)
        if row:
           data = {"item_id":item_id, "amount":row.amount+1}
           db.cart.delete("item_id", item_id)
           db.cart.put(data)
        else:
            data = {"item_id":item_id, "amount":1}
            db.cart.put(data)
            
            
    data = db.items.get_all()
    return render_template('products.html', data=data)