This includes two microservices in 2 separate Git repositories
- ImageStore
- ImageCompress
- Receives an uploaded image and returns a unique identifier which can then be used to retrieve the image
- Different image formats can be returned by using different extensions against the image ID
- Different image tarnsformations can be download using the image ID
- Calls the
ImageStore
service to retrieve the image using Image ID - Compresses the image
- Calls the
ImageStore
service to
- For ImageStore
pip install -r requirements.txt
export STORAGE_FOLDER=<path to your temp folder>
mkdir <path to your temp folder>
mkdir log
python app.py
- For ImageCompress
pip install -r requirements.txt
export STORE_URL=<url path to ImageStore service>
mkdir log
python app.py
curl -H "Content-Type: application/json" -X POST -d '{"filename":"table.jpg","type":"jpg"}' http://localhost:8000/upload
curl http://0.0.0.0:8000/download/<image ID for table.jpg>\?type\=jpg
curl http://0.0.0.0:8000/compress/<image ID for table.jpg>\?type\=jpg
curl http://0.0.0.0:8000/download/<image ID for table.jpg>\?type\=jpg\&transform=compress
To run in Docker Containers use the following docker-compose.yml
version: '3'
services:
store:
build: './ImageStore'
container_name: store
ports:
- 8000:8000
environment:
STORAGE_FOLDER: "/app/tmp"
compress:
build: './ImageCompress'
ports:
- 9000:9000
links:
- "store:imagestore"
environment:
STORE_URL: "http://store:8000"
The task management and HTTP request-response sequence between the client and the server as shown in the above diagram are implemenented in the Asynchronous Web Service project.
One could use Gevent or Celery for the task management and Redis or Rabbit as the message broker.