#StackBounty: #python #flask #websocket #pusher How can I set up a Pusher server with Flask?

Bounty: 50

I am trying to setup a simple flask server:

import envkey
import pysher
from flask import Flask
# from predictor import PythonPredictor
app = Flask(__name__)

pusher = pysher.Pusher(envkey.get('PUSHER_KEY'))

def my_func(*args, **kwargs):
    print("processing Args:", args)
    print("processing Kwargs:", kwargs)

# We can't subscribe until we've connected, so we use a callback handler
# to subscribe when able

def connect_handler(data):
    print('connect habndler')
    channel = pusher.subscribe('mychannel')
    channel.bind('myevent', my_func)

pusher.connection.bind('pusher:connection_established', connect_handler)

def index():


    return 'Server Works!'

But I Get an error:

RuntimeError: cannot join current thread

What am I doing wrong?

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.