Calling a function published to PiCloud ?

24 views
Skip to first unread message

TornadoRocks

unread,
Feb 17, 2012, 9:21:51 AM2/17/12
to pic...@googlegroups.com
Hi all, 
Pardon me if i'm missing anything.

and I have successfully published the function ( the example on creating a thumbnail ) to PiCloud.

I am having some issues with calling the function via Python.

The blog post mentioned that it uses Basic Auth to authenticate,
but i'm not quite sure how do i perform a Basic Auth and than upload an image to the function
published at PiCloud.

I was wondering if there's any sample code in Python that demonstrates how to perform the above action ?

I have checked out a few libraries:
https://github.com/kennethreitz/requests -> I received weird SSL certificate errors using this one
http://atlee.ca/software/poster/ -> i've read the tutorial, but it does not mention how do i perform a Basic Auth first before uploading an image.

Any advice ( code example as a python script or using the above mentioned libraries
 as to how to perform a Basic Auth and than uploading an image to the 
is welcomed!

Best.

Aaron Staley

unread,
Feb 18, 2012, 9:22:56 AM2/18/12
to pic...@googlegroups.com
Here's a quick example from the cloud library (network.py):

headers = {} # dictionary of http headers
base64string = base64.encodestring('%s:%s' % (api_key, secretkey))[:-1]  # encode api key and secretkey into base64
headers['Authorization'] = 'Basic %s' % base64string  # HTTP Authorization header provides authenication info

request = urllib2.Request('rest_url', headers = headers)  # build http request with our headers
response = urllib2_file.urlopen(request)  # issue request

More on HTTP authentication:

Hope this helps,
Aaron Staley
PiCloud, Inc.
Reply all
Reply to author
Forward
0 new messages