This project creates an API to implement and expose a few mathematical algorithms over REST API.
This app is developed on Python 3.8.3 and Flask 1.1.2. It also depends on Redis as well. You can either run the app on docker containers or run from local environments (like pyenv or virtualenv)
Before cloning the project; cache/database engine (Redis) service must be ready. You can either use docker-compose or install locally to manage these dependencies
After this step, clone the project and navigate into the project root.
➜ git clone git@github.com:ilhnctn/flask-example-app.git
➜ cd flask-example-app && python -m venv venv && source venv/bin/activate
➜ python -m pip install -r requirements/development.txt
You must copy the dist env file as below and fill your credentials.
➜ cp envs/dev.env.sample envs/dev.env
➜ git clone git@github.com:ilhnctn/flask-example-app.git && cd flask-example-app
➜ docker-compose up --build
You can also follow the Makefile to see more instructions about server management.
After either of the steps above, the api will be up and running on http://localhost:8080 (or whatever port supplied in docker-compose) This link contains an up-to-date Postman collection for all api services.
Test suits depend on pytest and coverage (not mandatory).
Important: Test dependencies are contained in development.txt requirements file, together with development and debug tools. In staging environments, this can be separated as well.
(venv) ➜ flask-example-app git:(develop) ✗ pytest
(venv) ➜ # or to run specific test
(venv) ➜ flask-example-app git:(develop) ✗ pytest apps/fibonacci/tests/test_service.py -k test_fails_when_unsupported_input_sent
(venv) ➜ # If you want to generate code coverage
(venv) ➜ flask-example-app git:(develop) ✗ coverage run -m pytest
- CI/CD Pipeline And test automation
- Caching: Add Redis layer on list endpoints
- Add custom Exception handling and improve logging
- Tests
- Service Tests
- Model Tests
- View Tests