Def - We are
Code
======================================
from flask import Flask
from flask import jsonify
from flask import request
from flask_pymongo import PyMongo
app = Flask(__name__)
app.config['MONGO_DBNAME'] = 'esawal'
app.config['MONGO_URI'] = 'mongodb://localhost:27017/esawal'
mongo = PyMongo(app)
@app.route('/', methods=['DELETE'])
def add_star():
myDB = mongo.db["customers"]
name = request.json['name']
# address = request.json['address']
star_id = myDB.delete_many({'name': name})
# OR TO DELETE ONE
# new_star = myDB.find()
star_id = myDB.delete_many({'name': name})
output = []
for s in myDB.find():
output.append({'name' : s['name'], 'address' : s['address']})
return jsonify({'result' : output})
if __name__ == '__main__':
app.run(debug=True)
======================================
OUTOUT
======================================
======================================
DELETE ONE
=======================================
star_id = myDB.delete_many({'name': name})
=======================================
Code
======================================
from flask import Flask
from flask import jsonify
from flask import request
from flask_pymongo import PyMongo
app = Flask(__name__)
app.config['MONGO_DBNAME'] = 'esawal'
app.config['MONGO_URI'] = 'mongodb://localhost:27017/esawal'
mongo = PyMongo(app)
@app.route('/', methods=['DELETE'])
def add_star():
myDB = mongo.db["customers"]
name = request.json['name']
# address = request.json['address']
star_id = myDB.delete_many({'name': name})
# OR TO DELETE ONE
# new_star = myDB.find()
star_id = myDB.delete_many({'name': name})
output = []
for s in myDB.find():
output.append({'name' : s['name'], 'address' : s['address']})
return jsonify({'result' : output})
if __name__ == '__main__':
app.run(debug=True)
======================================
OUTOUT
======================================
======================================
DELETE ONE
=======================================
star_id = myDB.delete_many({'name': name})
=======================================
No comments:
Post a Comment