https://github.com/bernardoadribeiro/basicflaskapp
This is a basic and containerized Flask application to help start coding using Flask in the backend.
https://github.com/bernardoadribeiro/basicflaskapp
docker docker-compose flask flask-sqlalchemy postgres python
Last synced: 3 months ago
JSON representation
This is a basic and containerized Flask application to help start coding using Flask in the backend.
- Host: GitHub
- URL: https://github.com/bernardoadribeiro/basicflaskapp
- Owner: bernardoadribeiro
- License: mit
- Created: 2022-12-18T17:22:30.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-02T00:17:44.000Z (about 3 years ago)
- Last Synced: 2025-07-02T14:48:58.864Z (12 months ago)
- Topics: docker, docker-compose, flask, flask-sqlalchemy, postgres, python
- Language: HTML
- Homepage:
- Size: 236 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Basic Flask Application
This is a basic and containerized Flask application to help start coding using Flask in the backend.
## Application Setup
> **Required:** `docker` and `docker-compose` must be installed in your machine.
### Technologies
- Docker e Docker compose
- Python + Flask + Flask-SQLAlchemy (ORM)
- Postgresql
### Images
- [postgres:10-alpine](https://hub.docker.com/_/postgres)
- [python:3.11-slim-buster](https://hub.docker.com/_/python)
- [adminer](https://hub.docker.com/_/adminer)
### Containers
- `web`: backend module running the flask application.
- `db`: database containers running the postgresql db
- `adminer`: database admin similiar to phpMyAdmin
### How to run the Flask application
> Run the following commands in the root directory.
**Commands:**
- Create .env file base on `.env.dist`: `cp .env.dist .env`
- Start containers: `docker-compose up` (use `-d` aferter up to start the container in the background)
- Stop containers: `docker-compose down`
**Migrations**
> - Run the following lines when needs to manage migrations:
> - Usage: `flask db [OPTIONS] COMMAND [ARGS]...`
- `flask db init`: to create a folder with set to migration.
- `flask db migrate -m "Initial migration."`: to generate a migration.
- `flask db [upgrade|downgrade]`: to up/down changes based on migration files.
- `flask db --help`: Show database help message.
**Tips**
- `__init__.py` files means that the directory is a package
- In `.env`:
- `SECRET_KEY`: This is a secret key to secure your session data and cookies of your application
- `FLASK_DEBUG`: It must be `False` when you deploy your application to `Production`
### **URLs**
- Flask App: http://localhost:8000/
- Adminer: http://localhost:8080/
### Resources
- [Flask doc](https://flask.palletsprojects.com/en/2.2.x/)
- [About Flask app environment configuration](https://flask.palletsprojects.com/en/2.2.x/config/)
- [Flask SQLAlchemy doc](https://flask-sqlalchemy.palletsprojects.com/en/3.0.x/)