Skip to content

Instantly share code, notes, and snippets.

@ImDineshSaini
Created January 31, 2019 20:26
Show Gist options
  • Save ImDineshSaini/33759eab16307f31515f63f00c615c45 to your computer and use it in GitHub Desktop.
Save ImDineshSaini/33759eab16307f31515f63f00c615c45 to your computer and use it in GitHub Desktop.
from flask import Flask
from pubsub import pub
import provision
app = Flask(__name__)
@app.route('/')
def hello_world():
print('Publish something via pubsub')
anObj = dict(a=456, b='abc')
pub.sendMessage('rootTopic', arg1=123, arg2=anObj)
return 'Hello World!'
@app.before_first_request
def activate_job():
pub.subscribe(provision.order_subscriber, 'rootTopic')
if __name__ == '__main__':
app.run()
def order_subscriber(arg1, arg2=None):
print('Function listener1 received:')
print(' arg1 =', arg1)
print(' arg2 =', arg2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment