API client that consumes pokemon data from pokeapi (pokemon API), caches it with Redis (using redis-py), and measures the response time.
- Flask
- Redis
Method | URI | Action |
---|---|---|
GET |
/api/pokemons |
Retrieve all pokemon 1 |
GET |
/api/pokemons/{id} |
Retrieve pokemon |
- Optional query parameters: limit, offset
http get http://localhost:5000/api/pokemons
{
"count": 949,
"results": [
{
"name": "bulbasaur",
"url": "https://pokeapi.co/api/v2/pokemon/1/"
},
{
"name": "ivysaur",
"url": "https://pokeapi.co/api/v2/pokemon/2/"
},
{
"name": "venusaur",
"url": "https://pokeapi.co/api/v2/pokemon/3/"
},
....
logged to console after first request:
retrieved pokemons from remote api in 0.62505s ms
logged to console after second request:
retrieved pokemons from cache in 0.00073s ms
With docker:
docker-compose build
docker-compose up
Go to http://localhost:5000 and visit one of the above endpoints
Alternatively, open config.py
and point the Redis URI to your server,
set the FLASK_APP
env variable to pokemon.py, and pip install the
dependencies (e.g. pip install -r requirements.txt
). Be sure to install the
python dependencies using requirements.txt
located in ./src/
, not
./src/requirements/
(I'm working on pruning the dev/prod/test dependencies).
cd
into ./pokemon
(if you are not already); then run:
flask run
Go to http://localhost:5000 and visit one of the above endpoints