Last active
October 31, 2017 06:15
-
-
Save tokida/d503f1cf9e616f166a5947702fa2db4a to your computer and use it in GitHub Desktop.
This file contains 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
import requests | |
import base64 | |
def main(dict): | |
# check dict | |
# dict { url } | |
dummy = 'https://2e1690af-4bca-4a99-9200-b1307b8f0427-bluemix.cloudant.com/photo/e447266d3d2dbb824e3ebfa2509c7f0c/sample.jpg' | |
geturl = '' | |
if ( dict.get('url',dummy) ): | |
geturl = dict.get('url',dummy) | |
response = requests.get(geturl, allow_redirects=False) | |
content_type = response.headers["content-type"] | |
b64 = base64.b64encode(response.content) | |
return { | |
'headers' : { | |
'Content-Type': content_type | |
}, | |
'statusCode': 200, | |
'body': b64 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OpenWhiskのWebActionのサンプル