from gevent import monkey monkey.patch_all() from app.main import app, socketio # from eventlet import monkey_patch # import redis # gevent.monkey.patch_all() if __name__ == "__main__": socketio.run(app, port=8000, debug=True)
# 主页 @app.route('/home') @login_required def home(): return render_template("layout/home.html", async_mode=socketio.async_mode) # 退出 @app.route('/logout') @login_required def logout(): session.pop('username', None) logout_user() # 登出用户 return redirect(url_for('login')) manager.add_command("shell", Shell(make_context=make_shell_context)) manager.add_command('db', MigrateCommand) # 新加入的代码,重写manager的run命令 manager.add_command( 'runserver', socketio.run(app=app, host='0.0.0.0', port=5000, use_reloader=False, debug=True)) if __name__ == '__main__': manager.run()
from app.main import app, socketio if __name__ == "__main__": socketio.run(app, debug=True)
#!/bin/env python from flask_socketio import SocketIO from app.main import app, socketio if __name__ == '__main__': # Setting debug=True enables the werkzeug debugger socketio.run(app, host='0.0.0.0', use_reloader=True, debug=True)
def run(): socketio.run(app, port=5001)
def run(): init_db() socketio.run(app, host='0.0.0.0', port=5000, use_reloader=True)
from app.main import app, socketio from app import config import eventlet if __name__ == '__main__': debug = False if hasattr(config, 'debug'): if config.debug == True: debug = True socketio.run(app, debug=debug)
from flask_socketio import SocketIO from app.main import app as application, socketio # Used to serve application with gunicorn if __name__ == "__main__": socketio.run(application)