Skip to content

Instantly share code, notes, and snippets.

@jaidevd
Created August 13, 2021 05:11
Show Gist options
  • Save jaidevd/138ff8854a2bce5dbdb02cfe8d242f68 to your computer and use it in GitHub Desktop.
Save jaidevd/138ff8854a2bce5dbdb02cfe8d242f68 to your computer and use it in GitHub Desktop.
Showing Images with FormHandler
url:
home:
pattern: /$YAMLURL/
handler: FunctionHandler
kwargs:
function: img.do
headers:
Content-Type: image/png
from scipy.misc import face
from PIL import Image
from io import BytesIO
x = face()
def do(handler):
with BytesIO() as buff:
Image.fromarray(x).save(buff, format="PNG")
buff.seek(0)
data = buff.read()
return data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment