Skip to content

Commit

Permalink
Use standard run command if flask-socketio isn't instantiated
Browse files Browse the repository at this point in the history
Fixes #347
  • Loading branch information
miguelgrinberg committed Nov 4, 2016
1 parent 88e829d commit 7af6740
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion flask_socketio/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys

from flask.cli import pass_script_info, get_debug_flag
from flask.cli import pass_script_info, get_debug_flag, run_command
import click


Expand Down Expand Up @@ -47,6 +48,12 @@ def run(info, host, port, reload, debugger, eager_loading):

def run_server():
app = info.load_app()
if 'socketio' not in app.extensions:
# flask-socketio is installed, but it isn't in this application
# so we invoke Flask's original run command
run_index = sys.argv.index('run')
sys.argv = sys.argv[run_index:]
return run_command()
socketio = app.extensions['socketio']
socketio.run(app, host=host, port=port, debug=debugger,
use_reloader=False, log_output=debugger)
Expand Down

0 comments on commit 7af6740

Please sign in to comment.