Skip to content

Instantly share code, notes, and snippets.

@umihico
Created September 3, 2019 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umihico/b920625e9c61f955cd604c0ca626ef98 to your computer and use it in GitHub Desktop.
Save umihico/b920625e9c61f955cd604c0ca626ef98 to your computer and use it in GitHub Desktop.
AWS Lambda function to return image
import requests
import base64
def lambda_handler(event, content):
response = requests.get("https://github.com/umihico.png")
return {
"isBase64Encoded": True,
"statusCode": 200,
"headers": { "content-type": "image/jpg"},
"body": base64.b64encode(response.content).decode("utf-8")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment