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

Method __init__

pywebio/platform/adaptor/http.py:341–380  ·  view source on GitHub ↗

Get the view function for running PyWebIO applications in Web framework. The view communicates with the client by HTTP protocol. :param callable app_loader: PyWebIO app factory, which receives the HttpContext instance as the parameter. Can not use `app_loader` and `appli

(self, applications=None, app_loader=None,
                 cdn=True,
                 session_expire_seconds=None,
                 session_cleanup_interval=None,
                 allowed_origins=None, check_origin=None)

Source from the content-addressed store, hash-verified

339 return context.get_response()
340
341 def __init__(self, applications=None, app_loader=None,
342 cdn=True,
343 session_expire_seconds=None,
344 session_cleanup_interval=None,
345 allowed_origins=None, check_origin=None):
346 """Get the view function for running PyWebIO applications in Web framework.
347 The view communicates with the client by HTTP protocol.
348
349 :param callable app_loader: PyWebIO app factory, which receives the HttpContext instance as the parameter.
350 Can not use `app_loader` and `applications` at the same time.
351
352 The rest arguments of the constructor have the same meaning as for :func:`pywebio.platform.flask.start_server()`
353 """
354 check_webio_js()
355
356 cls = type(self)
357
358 self.cdn = cdn
359 self.check_origin = check_origin
360 self.session_expire_seconds = session_expire_seconds or cls.DEFAULT_SESSION_EXPIRE_SECONDS
361 self.session_cleanup_interval = session_cleanup_interval or cls.DEFAULT_SESSIONS_CLEANUP_INTERVAL
362
363 assert applications is not None or app_loader is not None
364 if applications is not None:
365 applications = make_applications(applications)
366
367 def get_app(context):
368 app_name = context.request_url_parameter('app', 'index')
369 return applications.get(app_name) or applications['index']
370
371 self.app_loader = app_loader or get_app
372
373 for target in (applications or {}).values():
374 register_session_implement_for_target(target)
375
376 if check_origin is None:
377 self.check_origin = lambda origin: any(
378 fnmatch.fnmatch(origin, pattern)
379 for pattern in (allowed_origins or [])
380 )
381
382
383def run_event_loop(debug=False):

Callers

nothing calls this directly

Calls 3

check_webio_jsFunction · 0.85
make_applicationsFunction · 0.85

Tested by

no test coverage detected