[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[ice-dev] Python ICore update code
|
Everyone,
Here’s the code I was able to put together to let python post updates to a running Core instance.
import json
import requests
import base64
if __name__ == '__main__':
# Set the ICore url for updates
url = 'http://localhost:8080/ice/update'
# It requires the username:password be encoded
s = base64.b64encode('ice:veryice')
# Set up your json map
payload = {'some': 'data'}
# Set up the headers, These have to be here
headers = {'Authorization' : 'Basic ' + s, 'Content-type': 'application/x-www-form-urlencoded', 'Accept': 'text/plain'}
# Start a requests session
session = requests.session()
# Get the ICE update url
session.get(url)
# Post the json message with the given headers
r = session.post(url, json=payload, headers=headers)
print r
# Close the session
session.close()
Jordan, I imagine you should be able to start experimenting with the Peacock IO stuff using this code now.
Best,
Alex