Add mongo service communication
This commit is contained in:
@@ -5,31 +5,24 @@ from flask_pymongo import PyMongo
|
||||
# make sure mongoDB (container) is running and accessible
|
||||
|
||||
# see https://flask-pymongo.readthedocs.io/en/latest/
|
||||
from pymongo import MongoClient
|
||||
|
||||
app = Flask(__name__)
|
||||
#app.config["MONGO_URI"] = "mongodb://localhost:27017/myDatabase"
|
||||
#mongo = PyMongo(app)
|
||||
|
||||
#mongo.db.test.insert_one({'_id': 0, 'foo': {'test': 'this'}})
|
||||
#mongo.db.test.insert_one({'_id': 1, 'suu': 'sar'})
|
||||
|
||||
|
||||
#@app.route("/")
|
||||
#def home_page():
|
||||
# test_results = mongo.db.test.find()
|
||||
# results = []
|
||||
# try:
|
||||
# while True:
|
||||
# result = test_results.next()
|
||||
# results.append(result)
|
||||
# except StopIteration:
|
||||
# pass
|
||||
|
||||
#return str(results)
|
||||
app.config["MONGO_URI"] = "mongodb://mongo:27017/entities"
|
||||
mongo = PyMongo(app)
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
return str("Test!")
|
||||
test_results = mongo.db.cars.find()
|
||||
results = []
|
||||
try:
|
||||
while True:
|
||||
result = test_results.next()
|
||||
results.append(result)
|
||||
except StopIteration:
|
||||
pass
|
||||
|
||||
return str(results)
|
||||
|
||||
#if __name__ == '__main__':
|
||||
# app.run()
|
||||
|
||||
Reference in New Issue
Block a user