Giter Club home page Giter Club logo

api_sheet's Introduction

API Python

This project aims to provide endpoints for the extraction of basic data from an Excel file (.xlsx) and, also, a simple image conversion route.

Requirements

  • Python 3.7.2
  • Flask 1.1.2

Extra Libraries

  • Cross Origin Resource Sharing (CORS)

pip install -U flask-cors

  • pyjwt

pip install pyjwt

  • openpyxl

pip install openpyxl

  • Pyllow

pip install --upgrade Pillow

Installation

  • Install the requirements
  • Install and create a virtualenv

pip install virtualenv

  • Install the extra libraries
  • clone the reposotory

git clone https://github.com/JailsonS/api_sheetgo

Structure of Project

-> controllers [ it contains the controllers with the routes to perform conversion ]
-------> excelcontroller.py [ it contains the route and methods to read an excel file ]
-------> imagecontroller.py [ it contains the route and methods to read and convert an image file ]
-> models
-------> auth.py [ it contains information and methods to authenticate data ]
-> sample
-------> sample.xlsx [ it contains a simple xlsx file with some information. It can be used to test the routes ]

Testing the API

A very simple way to test the API is using the website https://resttesttest.com/. The endpoints that will be tested are:

  • [YOUR_BASE_DIR]/excel/info
  • [YOUR_BASE_DIR]/image/convert

Run the project

  • Activate the virtualenv and go to the project's directory
  • run the code below:

flask run

Testing [YOUR_BASE_DIR]/excel/info ROUTE

Go to https://resttesttest.com/, set the POST method and input PARAMETERS

Input data

  • email credentials, the parameter name must be "email" and the parameter value is one of the credentialed emails sent
  • .xlsx file the parameter name must be "sample_file" and the parameter value is the sample file in the Sample folder

Output data

  • json with some info: res_tab (tabs of the file ordered alphabetically), res (value of the first tab), jwt_token (JWT token encoded, the [b'] is not part of JWT!) If you want to check the JWT decoded go to https://jwt.io/#debugger-io and past only the JWT token response, mark "secret base64 encoded"

Testing [YOUR_BASE_DIR]/image/convert ROUTE

Input data

  • convert_type (PNG or JPEG), the parameter name must be "convert_type"
  • image file, the parameter name must be "input_img"

Output data

  • format - image format output
  • size - image size
  • mode - RGB
  • PIL_obj - Pillow Object
  • the converted image can be found in your root virtualenv dir

Examples

Testing route

res

Checking JWT

res_jwt

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.