Giter Site home page Giter Site logo

mfapi's Introduction

Multifile API with Flask and Docker

This repository pretends to be a boilerplate to process multiple files (such as images) in an isolate Docker container that provides an API to:

  • Send multiple files + parameters
  • Receive one processed file + parameters

I believe that it can be useful to integrate different parts of a pipeline that use different environments.

Example

In the following example, two images are sent from the client to the server API alongside some parameters. Then, the API blends the images and return the result and some parameters:

import requests

# Load multiple files
files=dict(img1=open('img1.png'),img2=open('img2.png'))

# Create some parameters
payload = {'param1': '0.5', 'param2': ['value2.1', 'value2.2']}

# Send files and parameters
response = requests.post('http://localhost:5000/',
    params=payload,
    files=files)

# Save the received file
with open('response_file.png', 'wb') as f:
    f.write(response.content)

# Print the received parameters
print(response.headers.get('key1'))
print(response.headers.get('key2'))

Usage

1- Use docker-compose up in the docker folder to start the Docker API.

2- The client send img1.png, img2.png and some parameters to the server. Use python send_files.py, in a new terminal.

3- The client will save the received file and print the returned parameters.

mfapi's People

Contributors

enric1994 avatar

Stargazers

David Azcona avatar

Watchers

James Cloos 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.