Code Monkey home page Code Monkey logo

app-rest-file-transfer's Introduction

REST secure file transfer app

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:

  1. 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).
  2. Convert the json file to xml, encrypt it with symmetric encryption.
  3. Send the encrypted file to the server endpoint '/upload/' using a POST request. Address and port are specified by env vars.
  4. 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.

Requirements

  • Python 3
  • Docker & docker-compose
  • Pip3 and pipenv

Built with

  • 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.

Installation

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

Usage

  • 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

app-rest-file-transfer's People

Contributors

dav-pascual avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.