This project contains solution created for the case.
In this project, a RESTful API created with single endpoint. According to explanations, when a request is received by that endpoint, an identicon similar to GitHub's approach is generated and returned to the client.
Project is completed in Python 3.6, and tested with both Python 3.6,8 and Python 3.6.10.
Flask web application framework is used for handling requests.
Pillow Python Image Library is used in order to generate and operate on image.
uwsgi is used for deployment.
First, an image should be built with the provided Dockerfile.
[sudo] docker build -t i-challenge .
Then, you can run api on the docker with the command below.
[sudo] docker run --rm -d -p 5000:5000 --name i-challenge i-challenge
You can follow logs with command below:
[sudo] docker logs -f i-challenge
At each request, program will be log some information about incoming request and operations performed on the api.
Firstly, you should set up a virtual environment. Then, steps mentioned at Run on local machine can be followed.
- Set up virtual environment
python3 -m venv [name of the virtual environment]
After running command above, a directory with the specified name have been created at in the project directory. You can activate that virtual environment with the command below:
source [virtual env name]/bin/activate
After that, you can follow steps at Run on local machine section.
- Ensure that Python 3.6 is installed
# python --version # or python3 --version # output: Python 3.[Minor.Patch]
- Ensure that pip is installed
# pip --version # or pip3 --version # output: pip [version] from [pip path] (python 3.[Minor])
- Install Flask, Pillow and uwsgi
pip3 install Flask && pip3 install Pillow
- Run api in Development mode
shell script export FLASK_APP=app.py flask run
In order to test that api, get request should be sent to specified url & port combination with or without query params. While testing, PostMan and curl are used.
Some test options are listed below.