diff --git a/api.py b/api.py new file mode 100644 index 0000000..3afda74 --- /dev/null +++ b/api.py @@ -0,0 +1,5 @@ +import urllib2 + +url = 'http://localhost:3000/api/coffeecups' +response = urllib2.urlopen(url).read() +print response diff --git a/ddp.py b/ddp.py deleted file mode 100644 index fa3c518..0000000 --- a/ddp.py +++ /dev/null @@ -1,59 +0,0 @@ -import time - -from MeteorClient import MeteorClient - -client = MeteorClient('ws://q42.nl/websocket') - - -def subscribed(subscription): - print('* SUBSCRIBED {}'.format(subscription)) - - -def unsubscribed(subscription): - print('* UNSUBSCRIBED {}'.format(subscription)) - - -def added(collection, id, fields): - print('* ADDED {} {}'.format(collection, id)) - for key, value in fields.items(): - print(' - FIELD {} {}'.format(key, value)) - - # query the data each time something has been added to - # a collection to see the data `grow` - all_lists = client.find('lists', selector={}) - print('Lists: {}'.format(all_lists)) - print('Num lists: {}'.format(len(all_lists))) - - # if collection == 'list' you could subscribe to the list here - # with something like - # client.subscribe('todos', id) - # all_todos = client.find('todos', selector={}) - # print 'Todos: {}'.format(all_todos) - - -def connected(): - print('* CONNECTED') - - -def subscription_callback(error): - if error: - print(error) - -client.on('subscribed', subscribed) -client.on('unsubscribed', unsubscribed) -client.on('added', added) -client.on('connected', connected) - -client.connect() -client.subscribe('publicLists') - - -# (sort of) hacky way to keep the client alive -# ctrl + c to kill the script -while True: - try: - time.sleep(1) - except KeyboardInterrupt: - break - -client.unsubscribe('publicLists')