# Collection of code snippets by Arne Vajhøj 
# (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import requests
import json

o = {'text': 'Hi from Python!'}
request1 = json.dumps(o)
response1 = requests.post('http://localhost:8001/msgs', headers = { 'Content-Type': 'application/json', 'Accept': 'application/json'}, data = request1)
response2 = requests.get('http://localhost:8001/msgs', headers = { 'Accept': 'application/json'})
msgs = json.loads(response2.text)
for msg in msgs['message']:
    print(msg['text'])
