Def
CODE
===========================================
from flask import Flask
from flask import jsonify
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=['GET'])
def get_all_stars():
star = mongo.db["customers"]
output = []
for s in star.find():
output.append({'address' : s['address'], 'name' : s['name']})
return jsonify({'result' : output})
if __name__ == '__main__':
# app.run(debug=True)
app.run(host='0.0.0.0', port=8000, debug=True) # It pick your system default IP
# or You can enter manual IP address of your pc
# app.run(host='192.168.1.102', port=8000, debug=True)
REQUEST AND RESPONSE
================================================
================================================
No comments:
Post a Comment