Help Center

Python - Flask + MySQL

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, giving developers great flexibility and freedom to choose the libraries and tools they want to use in their projects.

On the other hand, MySQL is a widely used open-source relational database management system that allows storing, organizing, and retrieving data efficiently. Developed by Oracle, MySQL offers high speed and reliability, facilitating data management through SQL queries. Its scalability, support for multiple platforms, and ability to integrate with numerous programming languages make it a popular choice for web and enterprise applications. MySQL is highly customizable and has an active developer community that contributes to its continuous improvement.

Project structure

text
.
├── app
│   ├── hello.py
│   └── requirements.txt
├── app.Dockerfile
├── compose.yaml
├── db
│   └── password.txt
└── README.txt

Deploying the application:

We change to the directory that contains the files required to build the container:

cd /root/stack/python/flask-mysql

Then we start the application:

text
docker compose up -d

Useful commands:

View 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