Created
January 31, 2019 20:26
-
-
Save ImDineshSaini/33759eab16307f31515f63f00c615c45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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