Get the ``RequestHandler`` class for running PyWebIO applications in Tornado. The ``RequestHandler`` communicates with the browser by HTTP protocol. The arguments of ``webio_handler()`` have the same meaning as for :func:`pywebio.platform.tornado_http.start_server` .. versionadded:: 1
(applications, cdn=True,
session_expire_seconds=None,
session_cleanup_interval=None,
allowed_origins=None, check_origin=None)
| 76 | |
| 77 | |
| 78 | def webio_handler(applications, cdn=True, |
| 79 | session_expire_seconds=None, |
| 80 | session_cleanup_interval=None, |
| 81 | allowed_origins=None, check_origin=None): |
| 82 | """Get the ``RequestHandler`` class for running PyWebIO applications in Tornado. |
| 83 | The ``RequestHandler`` communicates with the browser by HTTP protocol. |
| 84 | |
| 85 | The arguments of ``webio_handler()`` have the same meaning as for :func:`pywebio.platform.tornado_http.start_server` |
| 86 | |
| 87 | .. versionadded:: 1.2 |
| 88 | """ |
| 89 | cdn = cdn_validation(cdn, 'error') # if CDN is not available, raise error |
| 90 | |
| 91 | handler = HttpHandler(applications=applications, cdn=cdn, |
| 92 | session_expire_seconds=session_expire_seconds, |
| 93 | session_cleanup_interval=session_cleanup_interval, |
| 94 | allowed_origins=allowed_origins, check_origin=check_origin) |
| 95 | |
| 96 | class MainHandler(tornado.web.RequestHandler): |
| 97 | def options(self): |
| 98 | return self.get() |
| 99 | |
| 100 | def post(self): |
| 101 | return self.get() |
| 102 | |
| 103 | async def get(self): |
| 104 | context = TornadoHttpContext(self) |
| 105 | response = await handler.handle_request_async(context) |
| 106 | self.write(response) |
| 107 | |
| 108 | return MainHandler |
| 109 | |
| 110 | |
| 111 | def start_server(applications, port=8080, host='', |
no test coverage detected
searching dependent graphs…