This is Flask restful application which exposes player.csv file to rest api.
- flask_api directory - contains the following files:
app.py- the main file which run the app,requirements.txt- pre requisites packages,player.csv- the database of the application,README.md- about.srcpackage - contains the resources and configuration.resorcespackage - contains the api resourcesconfigpackage - contains the configuration classes of the app
testspackage - contains unit testing.
- endpoint:
http://127.0.0.1/player/<playerID>, method:GET, expected response (if found player): json which contain player attributes - endpoint:
http://127.0.0.1/players, method:GET, expected response: list of all the players
- Install Python
- Run
pip install -r requirements.txt - For test locally from the flask_api dir run:
python -m unittest -v tests/test_api.py - For run the from the flask_api dir run:
python ./app.py
- Install Docker
- For create the environment use:
docker compose up - For clean up the environment use:
docker compose down
I deployed it to ec2 and create for this project full AWS environment using ansible as deployment tool.
I used another repo as deployment repo and elaborated more there on how I deployed it to AWS.
- In the instructions write duplicate endpoint, the same one for players and player. I made assumption which it by mistake and split it.
- I made assumption that file can change during runtime, so I did 2 actions:
- Read the csv file in each request.
- Mount the csv file when using docker.
Author: Shahar Kozenyuk