Python socketio.Middleware() Examples
The following are 5
code examples of socketio.Middleware().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
socketio
, or try the search function
.
Example #1
Source File: runner.py From PokemonGo-Bot with MIT License | 5 votes |
def __init__(self, url): self.host, port_str = url.split(':') self.port = int(port_str) self.server = None # create the thread object self.thread = threading.Thread(target=self._start_listening_blocking) # wrap Flask application with socketio's middleware self.app = socketio.Middleware(sio, app)
Example #2
Source File: runner.py From PokemonGo-Bot-Backup with MIT License | 5 votes |
def __init__(self, url): self.host, port_str = url.split(':') self.port = int(port_str) self.server = None # create the thread object self.thread = threading.Thread(target=self._start_listening_blocking) # wrap Flask application with socketio's middleware self.app = socketio.Middleware(sio, app)
Example #3
Source File: ui_context.py From ravestate with BSD 3-Clause "New" or "Revised" License | 5 votes |
def ui_serve_events_async(self): app = flask.Flask(__name__, static_folder="dist/ravestate") app.wsgi_app = socketio.Middleware(self.sio, app.wsgi_app) ssl_context = self.conf(mod=RAVEBOARD, key=SSL_CRT_AND_KEY_CONTEXT) if not ssl_context or len(ssl_context) != 2: ssl_context = None else: ssl_context = tuple(ssl_context) app.run( host='0.0.0.0', port=self.conf(mod=RAVEBOARD, key=PORT_CONFIG_KEY), threaded=True, ssl_context=ssl_context)
Example #4
Source File: server.py From sdc-live-trainer with MIT License | 5 votes |
def start(self): self.sio = socketio.Server() self.sio.register_namespace(self) self.app = socketio.Middleware(self.sio, Flask(__name__)) eventlet.wsgi.server(eventlet.listen(('', 4567)), self.app)
Example #5
Source File: web.py From rd-usb with GNU General Public License v3.0 | 4 votes |
def run(browser=True): port = 5000 if len(sys.argv) > 1: port = int(sys.argv[1]) app = Flask(__name__, static_folder=static_path) app.register_blueprint(Index().register()) logger = logging.getLogger() logger.setLevel(logging.INFO) formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s") console = StreamHandler() console.setLevel(logging.DEBUG) console.setFormatter(formatter) logger.addHandler(console) if not app.debug: file = TimedRotatingFileHandler(data_path + "/error.log", when="w0", backupCount=14) file.setLevel(logging.ERROR) file.setFormatter(formatter) logger.addHandler(file) try: config = Config() secret_key = config.read("secret_key") if not secret_key: secret_key = "".join(random.choice(string.ascii_uppercase + string.digits) for _ in range(16)) config.write("secret_key", secret_key) app.secret_key = secret_key Storage().init() sockets = socketio.Server() app.wsgi_app = socketio.Middleware(sockets, app.wsgi_app) sockets.register_namespace(Backend()) def open_in_browser(): logging.info("Application is starting...") url = "http://127.0.0.1:%s" % port while not url_ok(url): sleep(0.5) logging.info("Application is available at " + url) if not app.debug and browser: webbrowser.open(url) Thread(target=open_in_browser, daemon=True).start() app.run(host="0.0.0.0", port=port, threaded=True, use_reloader=False) except (KeyboardInterrupt, SystemExit): raise except: logging.exception(sys.exc_info()[0])