Thumbnail generator API.
The application architecture is composed as follows:
The application is deployed trough AWS CloudFormation using Github Actions [pipeline file].
It is composed by two stages:
- test: execute unit tests using
unittests
module and create a coverage report using thecoverage
module. - build-and-deploy: build and deploy the application using
sam build
andsam deploy
.
The application has the following limitatinos:
- Maximum input file size is
10mb
, due toAWS API Gateway
. - Allowed input image types:
.PNG
and.JPEG
.
Create virtual environment:
python -m venv venv
source venv/bin/activate
Install dependencies:
pip install -r requirements.txt
Start the local server:
uvicorn src.app.main:app --reload --port 80
This will start a server at http://127.0.0.0:80.
Swagger documentation is available at: http://127.0.0.0:80/docs.
Use the following snippet to request a thumbnail using Python:
import io
import requests
from PIL import Image
if __name__ == "__main__":
with open("tests/horse.png", "rb") as f:
response = requests.post(
"http://127.0.0.1:80/create",
data={
"width": 128,
"height": 128,
"output_format": "png",
},
files={"file": f.read()},
)
image = Image.open(io.BytesIO(response.content))
image.show()
Import this postman collection to test the application out.