from flask import Flask, request from tapita import Cover from io import BytesIO import base64 app = Flask("tapas") @app.route('/', methods=['POST']) def handle(): """handle a request to the function Args: req (str): request body { "title": "foo", "subtitle": "bar", "author": "bat", } """ if not request: return "Foo", 200, {"Content-Type": "text/plain"} try: args = request.json except Exception: return "Bad Request", 400 c = Cover(**args) byte_arr = BytesIO() c.image.save(byte_arr, format="JPEG") return ( f'', 200, {"Content-Type": "text/html"}, ) @app.route('/ping') def ping(): return "OK"