keviocastro / python-flask-template

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python Flask Template

This is a Rest Api template using python and flask framework.

This template contains:

  • User authentication
  • Integration with Amazon AWS S3 and kraken for image optimize and storage
  • Migration scripts with Flask-Migrate
  • Some basic features: cities, groups, states and users

Step-by-step setup tutorial of the Python Flask Template.

The tutorial assumes that the user's OS is UNIX based, if not make the appropriate changes and select the correct OS in the documentation.

If running on Windows remember to enable Hyper-V and virtual environments.

Pre Requiments

create docker group, you'll probably have to reboot after this.

sudo groupadd docker
sudo usermod -aG docker $USER

Pycharm Integration

It's possible to run your container and debug with it using PyCharm.

  • Build, Execution, Deployment

To enable docker in PyCharm go to: File>Settings>Build,Execution,Deployment>Docker Enable Docker Click in the + icon and use the default settings

  • Project Interpreter

We need to create a remote python interpreter, basically the python interpreter running inside our container.

Go to File>Settings>Project: python-flask-template>Python Interpreter

Add a configuration clicking in the setting icon icon and clicking on "Add" and configure it like so: Docker Compose Config

  • Run/Debug Configurations

The final step in the setup is to configure the Run/Debug configuration, create one using the Remote Interpreter. Run/Debug Config

Deploy

First deploy

docker-compose up --build

Regular Deploy

docker-compose up

Once the project is up and running just debug the application by clicking in the debug icon debug icon

You ready to go!

  • Redeploy restoring all databases
bash init.sh

Migrations and DB

To make a migration on the database use:

docker-compose exec api flask db migrate -m"<your message>"

if there's a conflict with the migration heads, run:

bash db-merge.sh

About


Languages

Language:Python 97.0%Language:Shell 1.4%Language:Dockerfile 1.0%Language:Mako 0.6%