how to update mongodb using button in html, pymongo

Solution
from bson.objectid import ObjectId

@app.route("/update/:id", methods=["PATCH"])
def update_inventory(id):    
    client = MongoClient('mongodb://localhost:27017/')
    db = client.ecommerce
    id = ObjectId(request.values.get("_id"))
    db.items.update_one({ '_id': id}, {'$inc': {'inventory': -1}}, upsert=False)
    results2 = db.items.find()
    return render_template('base.html', data=results2)