miguelgrinberg / Flask-SocketIO-Chat

A simple chat application that demonstrates how to structure a Flask-SocketIO application.
http://blog.miguelgrinberg.com/post/easy-websockets-with-flask-and-gevent
MIT License
676 stars 242 forks source link

Changing the host parameter #12

Closed T81 closed 7 years ago

T81 commented 7 years ago

Hi Miguel, I'm trying to change the default host (127.0.0.1) to e.g 192.168.1.5 Following the next steps I still get wsgi starting up on http://_127.0.0.1_:5000 when I run the app

Edit: /app/init.py Change: def create_app(debug=False): to def create_app(host=None, debug=False): Add: app.host = host to the above function (above app.debug)

Edit: /chat.py Change: app = create_app(debug=True) to app = create_app(host='192.168.1.5', debug=True)

What am I missing?

miguelgrinberg commented 7 years ago

Are you passing the host keyword argument into socketio.run() as well?

T81 commented 7 years ago

socketio.run(app, host='192.168.1.5') did the trick! app = create_app(debug=True) in chat.py remains as is, it does not need the host argument passed

Thank you Miguel!

P.S Why app = create_app(debug=True) in chat.py enables the debugger but app = create_app(host='192.168.1.5', debug=True) does not change the host?

miguelgrinberg commented 7 years ago

The create_app function passes the debug setting through to the flask app it creates. It does not do the same with host, but you can easily add that functionality if you need it.