Coder Social home page Coder Social logo

rock-paper-scissors-deploy's Introduction

Flask Server Documentation

Overview

This documentation provides an overview of the Flask server API, specifically focusing on the /predict endpoint. The /predict endpoint is designed to receive three images encoded as base64 strings in a JSON object. The server processes the images and returns a JSON response containing the prediction result.

Endpoint Details

Endpoint: /predict

  • Method: POST
  • Input: JSON object containing three images encoded as base64 strings
  • Output: JSON response containing the prediction result or an error message

Request Format

The /predict endpoint expects a JSON object with the following structure:

{
  "images": [
    "base64_string_image1",
    "base64_string_image2",
    "base64_string_image3"
  ]
}
  • images: A list of three base64-encoded image strings.

Response Format

The server's response will be in the following JSON format:

{
  "result": "prediction_result"
}
  • result: A string containing the prediction result, which can be one of the following values: "Rock", "Paper", "Scissors", "No image".

Error Handling

If the server encounters an issue during processing or if the input data is not in the expected format, it will respond with an error message. The error response will have the following format:

{
  "error": "error_message"
}
  • error: A string describing the error that occurred.

Handling "No Image" Response

When the server responds with a prediction result of "No image", it indicates that there was an issue with the input images. This response should be properly handled on the frontend to provide appropriate feedback to the user. For instance, you can display an error message or a notification indicating that the images were not processed successfully.

Example Usage

Request

POST /predict
Content-Type: application/json

{
  "images": [
    "base64_string_image1",
    "base64_string_image2",
    "base64_string_image3"
  ]
}

Successful Response

HTTP/1.1 200 OK
Content-Type: application/json

{
  "result": "Rock"
}

Error Response

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
  "error": "Invalid input data"
}

Conclusion

The /predict endpoint of the Flask server is designed to receive three images as base64 strings and provide a prediction result based on the processed images. Proper handling of responses, including the "No image" case, is essential to ensure a smooth user experience on the frontend.

rock-paper-scissors-deploy's People

Contributors

ajibolamatthew1 avatar

Watchers

 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.