Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. @app.route('/tweets', methods=['GET'])
  2. def get_tweets():
  3.  
  4. client = MongoClient("localhost", 27017)
  5.  
  6. db = client['mongo']
  7. collection = db['pspi students']
  8.  
  9. cursor = collection.find({})
  10. json_docs = []
  11. for doc in cursor:
  12. json_doc = json.dumps(doc, default=json_util.default)
  13. json_docs.append(json_doc)
  14.  
  15. return jsonify(json_docs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement