This is a simple Flask-API boilerplate to help you quickly get started with setting up and deploying your python project. Here are some of the features of the setup:
- Docker Ready
- Kubernetes Ready
- Deployment Ready
i) Install Git
ii) Install Docker
To clone the project, run this command:
git clone git@github.com:GeoffMahugu/flask-backend.git
cd into project directory:
cd flask-backend
There are 2 states the app can run:
i) DevConfig: Has debug congigurations set on
ii) ProdConfig: This configuration has debug set off
To set the environments run this(This sets the environment variable in memmory - Do same in prod server):
ENV_CONFIG: being either DevConfig or ProdConfig
export APP_ENV=<ENV_CONFIG>
To run the project:
i. Build
docker-compose -f "docker-compose.yaml" up -d --build
ii. Run app
docker-compose up
To read more on docker: (link ☞)[README_Docker.md]
NOTE: During development, remember to build the image before runing the image. (That might just be the reason you are not seeing your upates)
i. Install PipEnv
Check version to make sure you are running python3
python --version
Proceed to install PipEnv
pip3 install pipenv
ii. Activate the Env
To activate the environment, run this command: PS: Will auto pick the configs from the (requirements.txt)[./requirements.txt] file.
pipenv shell
iii. Install dependancies
pipenv install
iv. Run project
python3 app.py
✦ /api This directory contains configurations for setting up the business logic Contains configurations for setting up API's
✦ /config Contains Global application configurations
✦ /models Contains configurations for modeling Database/iGraph. Do all ORM here.
✦ /static Contains any sattic files that needs to be served
✦ /tasks Contains configurations for any messaging process e.g Celery
i. Test Get-Request
url: http://127.0.0.1:5000/api/test-get
protocol: GET
response:
{
"You are task home": "API 1 Done"
}
ii. Test POST-Request
url: http://127.0.0.1:5000/api/test-igraph
protocol: POST
request:
{
"name": "John Doe",
"uuid": "=_ueyJhbGciOiJSUzI1NiIsImtp="
}
response:
{
"name": "John Doe",
"uuid": "=_ueyJhbGciOiJSUzI1NiIsImtp=",
"message": "Data has been processed"
}
This is a ist of usefull resources:
Feel free to use the project as a boilerplate to get you up and running quickly.
Any Pull Requests to improve the project and help other Python developers will be much appreciated 😀
With from the creator ❤️