Skip to content

Instantly share code, notes, and snippets.

@jmkelly
Created March 29, 2015 06:06
Show Gist options
  • Save jmkelly/4f793252203e7cc806b6 to your computer and use it in GitHub Desktop.
Save jmkelly/4f793252203e7cc806b6 to your computer and use it in GitHub Desktop.
http post from from queue
import pika
import requests
import json
def send_request(data, url):
headers = {'content-type': 'application/json'}
requests.post(url, data=data, headers=headers)
print "successfully: " + data
def on_message(channel, method_frame, header_frame, body):
send_request(body, "http://howhotismyshed.com.au/reading")
channel.basic_ack(delivery_tag=method_frame.delivery_tag)
connection = pika.BlockingConnection()
channel = connection.channel()
channel.basic_consume(on_message, 'temperatures')
try:
channel.start_consuming()
except KeyboardInterrupt:
channel.stop_consuming()
connection.close()
except:
exc_type, exc_value, exc_traceback = sys.exc_info()
print traceback.format_exc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment