当前位置: 首页>>代码示例>>Python>>正文


Python socketio.Middleware方法代码示例

本文整理汇总了Python中socketio.Middleware方法的典型用法代码示例。如果您正苦于以下问题:Python socketio.Middleware方法的具体用法?Python socketio.Middleware怎么用?Python socketio.Middleware使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在socketio的用法示例。


在下文中一共展示了socketio.Middleware方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import socketio [as 别名]
# 或者: from socketio import Middleware [as 别名]
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) 
开发者ID:PokemonGoF,项目名称:PokemonGo-Bot,代码行数:12,代码来源:runner.py

示例2: ui_serve_events_async

# 需要导入模块: import socketio [as 别名]
# 或者: from socketio import Middleware [as 别名]
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) 
开发者ID:Roboy,项目名称:ravestate,代码行数:15,代码来源:ui_context.py

示例3: start

# 需要导入模块: import socketio [as 别名]
# 或者: from socketio import Middleware [as 别名]
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) 
开发者ID:thomasantony,项目名称:sdc-live-trainer,代码行数:7,代码来源:server.py

示例4: run

# 需要导入模块: import socketio [as 别名]
# 或者: from socketio import Middleware [as 别名]
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]) 
开发者ID:kolinger,项目名称:rd-usb,代码行数:59,代码来源:web.py


注:本文中的socketio.Middleware方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。