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

Function webio_handler

pywebio/platform/tornado_http.py:78–108  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

76
77
78def 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
111def start_server(applications, port=8080, host='',

Callers 1

start_serverFunction · 0.70

Calls 2

cdn_validationFunction · 0.85
HttpHandlerClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…