Skip to content

Instantly share code, notes, and snippets.

@merylldindin
Last active February 10, 2020 06:35
Show Gist options
  • Save merylldindin/efe08fac43edc301723eac15591348d1 to your computer and use it in GitHub Desktop.
Save merylldindin/efe08fac43edc301723eac15591348d1 to your computer and use it in GitHub Desktop.
# Initialize the Flask application
application = Flask(__name__)
app_sockets = Sockets(application)
# Websocket usage example
@app_sockets.route('/stream')
def stream(websocket):
while not websocket.closed:
msg = websocket.receive()
if msg is None: continue
else: do_something_smart(msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment