This project contains two independent python apps, app-receiver and app-sender (an HTTP-REST server and client respectively).
app-receiver is a simple restful application written in python Flask framework and hosted with gunicorn. It provides two rest interfaces:
- GET '/': Checks the health of the service. Returns 200 with json response when successful.
- POST '/upload/': Accepts a file in the form of multipart/form-data. Upon successful receipt of the file, it will be decrypted and stored to a location specified with OUTPUT_DIR environment variable.
app-sender acts as a client to app-receive. It will:
- Scan for json files in an input directory and verify if has been processed before (if that is the case, it will skip and move to the next file).
- Convert the json file to xml, encrypt it with symmetric encryption.
- Send the encrypted file to the server endpoint '/upload/' using a POST request. Address and port are specified by env vars.
- The server (app-receiver) will receive the file and decrypt it using the same key, and save it. If everything went well, it will send back a successful HTTP response.
- Python 3
- Docker & docker-compose
- Pip3 and pipenv
- Python 3 & Flask: webapp development.
- pytest: testing framework.
- Fernet library: Python library to encrypt/decrypt files using symmetric encryption.
- Docker: For the containerization of the app.
To create a python virtual enviroment in our machine we can execute in app-receiver and app-sender directories:
$ pipenv install --dev
Or we could just use docker-compose in the following way:
$ docker-compose -f docker-compose.yml build --no-cache
- If you want to execute both apps directly on our machine do as it follows:
In '/app-receiver/receiver/':
$ gunicorn server:app
In '/app-sender/' execute:
$ python3 server
- To run the apps in containers, in the base path run:
$ docker-compose up --build
Put json files in the specified input directory to be processed.
- To run unit tests on app-receiver (server), in '/app-receiver/' execute:
$ pytest -v tests