miguelgrinberg/Flask-SocketIO-Chat

Understanding the structure

Closed this issue · 3 comments

Hi Miguel,

I have a couple of questions about this example:

  1. In your code you don't have any lines like this: app.register_blueprint(...). I normally have this in my main entry point after I've gotten an 'app' instance. Is this unnecessary? I wanted to understand this better.
  2. I found this example code while trying to understand how to use Blueprint with websockets. Based on your code it looks like Blueprints (and any kind of 'url_prefix') aren't used with websockets, and any kind of 'url_prefix' should be handled with a socketio namespace parameter in the decorator. Is that correct?

Thanks in advance for your help!
Doug

  1. I do have register_blueprint() actually. It's in the application factory function: https://github.com/miguelgrinberg/Flask-SocketIO-Chat/blob/master/app/__init__.py#L14.
  2. Correct, blueprints are a Flask feature, nothing to do with Flask-SocketIO.

Thanks for the clarification, I don't know how I missed the register_blueprint in the create_app() function, sorry for D'OH moment on my part.

Also, thanks also for the clarification that Blueprints isn't used with Flask-SocketIO. Based on the structure of the app folders I was mistakenly looking for a connection there.

No problem. I could see how this can be a bit confusing. Maybe I should have placed the events.py module outside of the main package so that it is more clear that it is not part of the blueprint. As things are, the main package contains both the blueprint and the Socket.IO stuff.