Created
August 24, 2015 19:47
-
-
Save doobeh/b9fd018d199c72465fb8 to your computer and use it in GitHub Desktop.
Blinker/Signal Flask Example
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, current_app | |
from blinker import Namespace | |
app = Flask(__name__) | |
app.secret_key = 'WOO' | |
my_signals = Namespace() | |
def moo_signal(app, message, **extra): | |
print(message) | |
moo = my_signals.signal('moo') | |
moo.connect(moo_signal, app) | |
@app.route('/', methods=['POST', 'GET']) | |
def home(): | |
moo.send(current_app._get_current_object(), message='Hi') | |
moo.send(current_app._get_current_object(), message='Hi') | |
moo.send(current_app._get_current_object(), message='Hi') | |
return 'toot' | |
if __name__ == '__main__': | |
app.run(debug=True, port=5002) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment