The task was to create microservice, that is able to take an country ISO code and a list of country names (in different languages) as an input. It will filter out just the countries that correspond to the provided ISO code.
Serve the application as the API.
The countries has to be in right format for given language, on the other hand, iso is not a case sensitive parameter. Supports both, 3166-1 alpha-2 and ISO 3166-1 alpha-3. Also, it does not preserve the order of "out filtered" countries, can be changed in code by uncommenting one single line.
This code was developed on Windows 10 running Python 3.10.2
POST http://127.0.0.1:8000/match_country
{
"iso": "fra",
"countries": [
"Slovakia",
"Slovensko",
"Czechia",
"Česko",
"Botswana",
"Taiwan",
"Francúzsko",
"Frankreich",
"France",
"Francie"
]
}
{
"iso": "fra",
"match_count": 4,
"matches": [
"Frankreich",
"Francúzsko",
"France",
"Francie"
]
}
Swagger can be accessed at: http://127.0.0.1:8000/redoc or here.
Clone the project
git clone https://github.com/Ad4mk0/iso-assignment.git
Go to the project directory
cd iso-assignment
Use docker
docker-compose up
To run tests, run the following command
docker exec -it fastapi pytest
If you would like to add tests of your own, modify test_api.py file
This project also contains FE app, pyscript.html, so you can engage with the API interactively in your browser.
Docker hub repository can be found here.