This is an python ๐ with flask ๐ถ๏ธ api to management the blacklist for a company
You can check the postman documentation make a clic in the next
URL: https://documenter.getpostman.com/view/1347256/2sA3Bj7Z4w
- Python ๐
- Docker & docker-compose ๐ณ (Optional).
- For Linux ๐ง and mac ๐ you can use makefile.
- For Windows ๐ช you can use bash function.
If you want execute without docker then you must execute the next commands in your terminal. Note: firstable is important that you have your python virtual environmente created.
- Firstly, you should have the .env please follow the file .env.example you should have something like this
FLASK_APP=flaskr/app
FLASK_ENV=development
APP_NAME=codesquad-blacklist-api
SECRET_KEY=[SECRET_KEY]
JWT_SECRET_KEY=[SECRET_KEY]
DATA_BASE_URI=[DATA_BASE_URL]
The .env.dev for your local environment
FLASK_APP=flaskr/app
FLASK_ENV=development
APP_NAME=codesquad-blacklist-api
SECRET_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbnZpcm9ubWVudCI6ImRldmVsb3BtZW50IiwiYXBwbGljYXRpb24iOiJjb2Rlc3F1YWQtYmxhY2tsaXN0LWFwaSJ9.yJu4GXzVheB7U4VNFAEc2iElgUYf3UtQErhHDDK2vgo
JWT_SECRET_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbnZpcm9ubWVudCI6ImRldmVsb3BtZW50IiwiYXBwbGljYXRpb24iOiJjb2Rlc3F1YWQtYmxhY2tsaXN0LWFwaSJ9.yJu4GXzVheB7U4VNFAEc2iElgUYf3UtQErhHDDK2vgo
DATA_BASE_URI=postgresql://postgres:postgres@db:5432/blacklist
The .env.db for your local db environment
POSTGRES_DB=blacklist
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_PORT=5432
PGPORT=5432
- First step you should activate the python environment
# With Linux ๐ง or Mac ๐
make activate
# With Windows ๐ช
source run.sh; activate
# With python flask ๐ ๐ถ๏ธ
python3 -m venv venv
source venv/bin/activate
- Second step you should install all the dependencies and python ๐ packages ๐ฆ
# With Linux ๐ง or Mac ๐
make install
# With Windows ๐ช
source run.sh; install
# With python flask ๐ ๐ถ๏ธ
pip install -r requirements.txt
- Finally, into directory flaskr execute
# With Linux ๐ง or Mac ๐ you can send a specific port with port=5000 param
make run
#or
make run port=5000
# With Windows ๐ช you can send a specific port with 5000 param
source run.sh; run
# or
source run.sh; run 5000
# With python flask ๐ ๐ถ๏ธ
flask run
- Step one locate in the root of the project
cd codsquad-backlist-api
- Run in docker ๐ณ
# With Linux ๐ง or Mac ๐
make docker-dev-up
# Command to run with nginx and proxy reverse
make docker-up
# With Windows ๐ช
source run.sh; docker_dev_up
# Command to run with nginx and proxy reverse
source run.sh; docker_up
# With docker compose for all Operative Systems
docker compose -f=docker-compose.develop.yml up --build
# Command to run with nginx and proxy reverse
docker compose up --build
- Make sure that all microservices are running
- Executing this command
docker ps
You can call the health check, for example:
$ curl -X GET --location 'http://localhost:5000/health'
You must receive a request like next:
{
"environment": "development",
"application": "codesquad-blacklist-api",
"status": 200
}
-
You should have the collection inside a postman folder
-
You should have the postman collection and environment imported in your postman application
-
For endpoint POST blacklist, you should have configured the next pre request script
Important
You could find this in the postman folder as pre-script.js
const uuid = require('uuid');
const generatedUUID = uuid.v4();
const jsonData = JSON.parse(pm.request.body);
const email = jsonData.email;
pm.environment.set("CODESQUAD_BLACKLIST_UUID", generatedUUID);
pm.environment.set("CODESQUAD_BLACKLIST_EMAIL", email);