Handle empty requests for ping, add a bit of styling

This commit is contained in:
Roberto Alsina 2023-05-16 14:01:04 -03:00
parent b520913c47
commit 3cb29002df
1 changed files with 3 additions and 1 deletions

View File

@ -15,6 +15,8 @@ def handle(req):
"author": "bat", "author": "bat",
} }
""" """
if not req:
return "Foo", 200, {"Content-Type": "text/plain"}
try: try:
args = loads(req) args = loads(req)
except Exception: except Exception:
@ -25,7 +27,7 @@ def handle(req):
c.image.save(byte_arr, format="JPEG") c.image.save(byte_arr, format="JPEG")
return ( return (
f'<img src="data:image/jpeg;base64, {base64.b64encode(byte_arr.getvalue()).decode("utf-8")}">', f'<img src="data:image/jpeg;base64, {base64.b64encode(byte_arr.getvalue()).decode("utf-8")}" style="width: 100%; border: solid 1px #aaa;">',
200, 200,
{"Content-Type": "text/html"}, {"Content-Type": "text/html"},
) )