Skip to content

Instantly share code, notes, and snippets.

@snobu
Last active March 2, 2017 14:30
Show Gist options
  • Select an option

  • Save snobu/6121757ab571218fe71534fa4bc1ac37 to your computer and use it in GitHub Desktop.

Select an option

Save snobu/6121757ab571218fe71534fa4bc1ac37 to your computer and use it in GitHub Desktop.
temp-gist
from __future__ import absolute_import, unicode_literals
import sys, os, cStringIO, urllib, base64
import json
# Add function directory to import path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname( __file__ ))))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname( __file__ ), 'lib')))
from AzureHTTPHelper import HTTPHelper
http = HTTPHelper()
output_path = os.path.join(workingdir, 'output.jpg')
jpegfile = open(output_path, mode='rb') # b = binary
rawjpegbytes = jpegfile.read()
# ascii response body
returnData = {
#HTTP Status Code:
"status": 200,
#Response Body:
"body": "SOME TEXT",
# Send any number of HTTP headers
"headers": {
"Content-Type": "image/jpeg"
}
}
# Output the response to the client
output = open(os.environ['res'], 'w')
# binary response body
output.write(rawjpegbytes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment