32 lines
689 B
Python
32 lines
689 B
Python
import jsonify as jsonify
|
|
from flask import Flask
|
|
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://mongo:27017/entities"
|
|
mongo = PyMongo(app)
|
|
|
|
@app.route("/")
|
|
def index():
|
|
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()
|
|
|
|
if __name__ == '__main__':
|
|
app.run(host='0.0.0.0')
|