Help Center

Python - Flask - Mongo

Flask is a lightweight and flexible web framework written in Python that is used to build web applications. Flask is classified as a “microframework” because it provides the essential tools to create web applications but does not impose a specific structure or components, which gives developers great flexibility and freedom to choose the libraries and tools they want to use in their projects.

On the other hand MongoDB is an open-source NoSQL database based on a flexible and scalable data model, known as BSON document storage. Instead of tables and rows like in relational databases, MongoDB stores data in JSON-like documents, allowing a more natural representation of complex data. It is highly scalable and can handle large volumes of data, distributing load across clusters and offering replication for high availability. MongoDB is widely used in web, mobile applications and projects that require rapid iteration in development and agile storage of unstructured or semi-structured data.

Project structure

text
.
├── compose.yaml
├── app.Dockerfile
├── app
    ├── requirements.txt
    └── server.py

Application deployment:

We go to the directory that contains the files needed to build the container:

cd /root/stack/python/flask-mongo

And bring up the application:

text
docker compose up -d

Useful commands:

List the containers that are running:

text
docker compose ps

Stop and remove the application:

text
docker compose down

Rebuild the application after making changes to the code:

text
docker compose --build -d