heroku-python / flask-sockets

[DEPRECATED] Alternative: https://github.com/miguelgrinberg/flask-sock
MIT License
1.74k stars 167 forks source link

blueprint issue #42

Closed winster closed 7 years ago

winster commented 7 years ago

In my router.py, when I tried to create sockets object, it failed with following error

AttributeError: 'Blueprint' object has no attribute 'wsgi_app'

This is how I tried to create sockets object.

router = Blueprint('router', __name__)
sockets = Sockets(router)

Since above statements didnt work, I also tried to put the following code in __init.py__:

from router import router
app.register_blueprint(router)
sockets = Sockets(router)
sockets.register_blueprint(router)

How to fix this?

o3bvv commented 7 years ago

@winster If you've figured out the root of the problem, please, do not delete bodies of issues even if they are not related to the library itself.

Project contributors receive original issue reports on emails, so issue bodies can be restored.

Other people may face problems similar to yours and any help can save their time. However, deleted issue messages can confuse everyone.

This is a general advise on collaborating with others.

Thanks

winster commented 7 years ago

@oblalex sorry for that. I deleted this because, I didn't notice the blueprint sample in README. You may please restore the body. I will update my fix here.

This is how I fixed it as per the sample given in README.

in init.py put this code

from router import router, ws
app.register_blueprint(router)
sockets = Sockets(app)
sockets.register_blueprint(ws)

and in router.py put this code

router = Blueprint('router', __name__)
ws = Blueprint('ws', __name__)
o3bvv commented 7 years ago

@winster done, thanks