Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask, jsonify, request, abort, make_response
- import datetime
- import zmq
- import threading
- import time
- import requests
- app = Flask(__name__)
- @app.route('/itemd', methods = ['POST'])
- def post_item() :
- zpush.send_json(request.json)
- def consumer():
- print 'CONSUMER STARTED'
- zpullctx = zmq.Context()
- zpull = zpushctx.socket(zmq.PULL)
- zpull.connect("inproc://zmq1")
- while True:
- data = zpull.recv_json()
- print data
- if __name__ == '__main__':
- zpushctx = zmq.Context()
- zpush = zpushctx.socket(zmq.PUSH)
- zpush.bind("tcp://127.0.0.1:5557")
- time.sleep(0.1)
- threading.Thread(target=consumer,).start()
- app.run(debug = True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement