New minisite: book covers
Since I wrote tapita to automatically create book covers, it was absurdly easy to turn it into a site where you can create book covers.
So, you can go to Covers.ralsina.me and create book covers.
Fun part: this is the whole backend for the site:
from json import loads
from tapita import Cover
from io import BytesIO
import base64
def handle(req):
"""handle a request to the function
Args:
req (str): request body
{
"title": "foo",
"subtitle": "bar",
"author": "bat",
}
"""
try:
args = loads(req)
except Exception:
return "Bad Request", 400
c = Cover(**args)
byte_arr = BytesIO()
c.image.save(byte_arr, format="JPEG")
return (
f'<img src="data:image/jpeg;base64, {base64.b64encode(byte_arr.getvalue()).decode("utf-8")}">',
200,
{"Content-Type": "text/html"},