MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / webio_handler

Function webio_handler

pywebio/platform/tornado.py:160–178  ·  view source on GitHub ↗

Get the ``RequestHandler`` class for running PyWebIO applications in Tornado. The ``RequestHandler`` communicates with the browser by WebSocket protocol. The arguments of ``webio_handler()`` have the same meaning as for :func:`pywebio.platform.tornado.start_server`

(applications, cdn=True, reconnect_timeout=0, allowed_origins=None, check_origin=None)

Source from the content-addressed store, hash-verified

158
159
160def webio_handler(applications, cdn=True, reconnect_timeout=0, allowed_origins=None, check_origin=None):
161 """Get the ``RequestHandler`` class for running PyWebIO applications in Tornado.
162 The ``RequestHandler`` communicates with the browser by WebSocket protocol.
163
164 The arguments of ``webio_handler()`` have the same meaning as for :func:`pywebio.platform.tornado.start_server`
165 """
166 applications = make_applications(applications)
167 for target in applications.values():
168 register_session_implement_for_target(target)
169
170 cdn = cdn_validation(cdn, 'error') # if CDN is not available, raise error
171
172 if check_origin is None:
173 check_origin_func = partial(_check_origin, allowed_origins=allowed_origins or [])
174 else:
175 check_origin_func = lambda origin, handler: _is_same_site(origin, handler) or check_origin(origin)
176
177 return _webio_handler(applications=applications, cdn=cdn, check_origin_func=check_origin_func,
178 reconnect_timeout=reconnect_timeout)
179
180
181async def open_webbrowser_on_server_started(host, port):

Callers 2

start_test_serverFunction · 0.90
start_serverFunction · 0.70

Calls 5

make_applicationsFunction · 0.85
cdn_validationFunction · 0.85
_is_same_siteFunction · 0.70
_webio_handlerFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…