Skip to content

Instantly share code, notes, and snippets.

@tokida
Last active October 31, 2017 06:15
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 tokida/d503f1cf9e616f166a5947702fa2db4a to your computer and use it in GitHub Desktop.
Save tokida/d503f1cf9e616f166a5947702fa2db4a to your computer and use it in GitHub Desktop.
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
}
@tokida
Copy link
Author

tokida commented Oct 31, 2017

OpenWhiskのWebActionのサンプル

  • 画像データを返す

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment