Help Center

Python - Flask + MySQL

Flask is a lightweight and flexible web framework written in Python 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 community of developers contributing to its continuous improvement.

Project structure

text
.
โ”œโ”€โ”€ app
โ”‚ย ย  โ”œโ”€โ”€ hello.py
โ”‚ย ย  โ””โ”€โ”€ requirements.txt
โ”œโ”€โ”€ app.Dockerfile
โ”œโ”€โ”€ compose.yaml
โ”œโ”€โ”€ nginx
โ”‚ย ย  โ””โ”€โ”€ default.conf
โ”œโ”€โ”€ backup
โ”‚ย ย  โ””โ”€โ”€ backup-runner.sh
โ”œโ”€โ”€ .env
โ””โ”€โ”€ .env.example

Application deployment:

Change to the directory that contains the files necessary to build the container:

cd /root/stack/python/flask-mysql

Then start the application:

text
docker compose up -d

Useful commands:

View the running containers:

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 up -d --build
Guide g.0314 ยท Source version 1 ยท en