Skip to content

Commit

Permalink
discontinue the customized flask run command
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Jan 22, 2019
1 parent afbd83e commit 9bde4be
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 78 deletions.
12 changes: 7 additions & 5 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ Werkzeug development server is still used and configured properly inside
available, else the gevent web server is used. If eventlet and gevent are not
installed, the Werkzeug development web server is used.

The command line interface based on click introduced in Flask 0.11 is also
supported. This extension provides a new version of the ``flask run`` command
that is appropriate for starting the Socket.IO server. Example usage::

$ FLASK_APP=my_app.py flask run
The ``flask run`` command introduced in Flask 0.11 can be used to start a
Flask-SocketIO development server based on Werkzeug, but this method of starting
the Flask-SocketIO server is not recommended due to lack of WebSocket support.
Previous versions of this package included a customized version of the
``flask run`` command that allowed the use of WebSocket on eventlet and gevent
production servers, but this functionality has been discontinued in favor of the
``socketio.run(app)`` startup method shown above.

The application must serve a page to the client that loads the Socket.IO
library and establishes a connection::
Expand Down
12 changes: 12 additions & 0 deletions flask_socketio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import sys

# make sure gevent-socketio is not installed, as it conflicts with
Expand Down Expand Up @@ -210,6 +211,17 @@ def loads(*args, **kwargs):
self.server_options.pop('resource', None) or 'socket.io'
if resource.startswith('/'):
resource = resource[1:]
if os.environ.get('FLASK_RUN_FROM_CLI'):
if self.server_options.get('async_mode') is None:
app.logger.warning(
'Flask-SocketIO is Running under Werkzeug, WebSocket is '
'not available.')
self.server_options['async_mode'] = 'threading'
elif self.server_options['async_mode'] != 'threading':
raise RuntimeError(
'The "flask run" command does not support {}, please '
'start your server with "socketio.run(app)".'.format(
self.server_options['async_mode']))
self.server = socketio.Server(**self.server_options)
self.async_mode = self.server.async_mode
for handler in self.handlers:
Expand Down
68 changes: 0 additions & 68 deletions flask_socketio/cli.py

This file was deleted.

5 changes: 0 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
zip_safe=False,
include_package_data=True,
platforms='any',
entry_points={
'flask.commands': [
'run=flask_socketio.cli:run'
],
},
install_requires=[
'Flask>=0.9',
'python-socketio>=2.1.0'
Expand Down

0 comments on commit 9bde4be

Please sign in to comment.