Skip to content

Minecraftschurli/flask_tinify

Repository files navigation

flask_tinify Build

An adaption of tinify as a flask extension

Installation

Install the API client:

pip install flask-tinify

Usage

from flask import Flask
from flask_tinify import Tinify

app = Flask(__name__)
tinify = Tinify(app)

Basic example

from flask import Flask, request
from flask_tinify import Tinify

app = Flask(__name__)
tinify = Tinify(app)

@app.route('/tinify', methods=['POST'])
def hello_png():
    image = request.form['image']
    if not image:
        return '', 400
    with image.strem as stream:
        tinify.from_buffer(stream.read()).to_buffer()