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)
| 126 | |
| 127 | |
| 128 | def 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 | |
| 159 | def static_routes(prefix='/'): |
no test coverage detected
searching dependent graphs…