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

Function webio_handler

pywebio/platform/aiohttp.py:128–156  ·  view source on GitHub ↗

Get the `Request Handler `_ coroutine for running PyWebIO applications in aiohttp. The handler communicates with the browser by WebSocket protocol. The arguments of ``webio_handler()`` have the same meaning as for :

(applications, cdn=True, reconnect_timeout=0, allowed_origins=None, check_origin=None,
                  max_payload_size='200M', websocket_settings=None)

Source from the content-addressed store, hash-verified

126
127
128def webio_handler(applications, cdn=True, reconnect_timeout=0, allowed_origins=None, check_origin=None,
129 max_payload_size='200M', websocket_settings=None):
130 """Get the `Request Handler <https://docs.aiohttp.org/en/stable/web_quickstart.html#aiohttp-web-handler>`_ coroutine for running PyWebIO applications in aiohttp.
131 The handler communicates with the browser by WebSocket protocol.
132
133 The arguments of ``webio_handler()`` have the same meaning as for :func:`pywebio.platform.aiohttp.start_server`
134
135 :return: aiohttp Request Handler
136 """
137 applications = make_applications(applications)
138 for target in applications.values():
139 register_session_implement_for_target(target)
140
141 websocket_settings = websocket_settings or {}
142
143 page.MAX_PAYLOAD_SIZE = max_payload_size = parse_file_size(max_payload_size)
144 websocket_settings.setdefault('max_msg_size', max_payload_size)
145
146 cdn = cdn_validation(cdn, 'error')
147
148 if check_origin is None:
149 check_origin_func = partial(_check_origin, allowed_origins=allowed_origins or [])
150 else:
151 check_origin_func = lambda origin, host: _is_same_site(origin, host) or check_origin(origin)
152
153 return _webio_handler(applications=applications, cdn=cdn,
154 check_origin_func=check_origin_func,
155 reconnect_timeout=reconnect_timeout,
156 websocket_settings=websocket_settings)
157
158
159def static_routes(prefix='/'):

Callers 3

start_test_serverFunction · 0.90
start_serverFunction · 0.70
path_deployFunction · 0.70

Calls 6

make_applicationsFunction · 0.85
parse_file_sizeFunction · 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…