Minimal setup for building a Python API running with Flask and MongoDB, inside Docker Containers
docker-compose build
docker-compose up
- install MongoDB
- install Python 3
- install
pip
- run
pip install -r requirements.txt
- run
FLASK_APP=app.py flask run
to start the server (orpython -u app.py
) - change the lines
if __name__ == "__main__":
app.run(host="0.0.0.0", debug=True)
to simply:
app.run(debug=True)
and
client = MongoClient('mongodb://db:27017/')
to
client = MongoClient('mongodb://localhost:27017/')