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)
| 158 | |
| 159 | |
| 160 | def 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 | |
| 181 | async def open_webbrowser_on_server_started(host, port): |
no test coverage detected
searching dependent graphs…