Created
August 13, 2021 05:11
-
-
Save jaidevd/138ff8854a2bce5dbdb02cfe8d242f68 to your computer and use it in GitHub Desktop.
Showing Images with FormHandler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
url: | |
home: | |
pattern: /$YAMLURL/ | |
handler: FunctionHandler | |
kwargs: | |
function: img.do | |
headers: | |
Content-Type: image/png |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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