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

Function path_deploy_http

pywebio/platform/path_deploy.py:293–361  ·  view source on GitHub ↗

Deploy the PyWebIO applications from a directory. The server communicates with the browser using HTTP protocol. The ``base``, ``port``, ``host``, ``index``, ``static_dir`` arguments of ``path_deploy_http()`` have the same meaning as for :func:`pywebio.platform.path_deploy` The res

(base, port=0, host='',
                     index=True, static_dir=None,
                     cdn=True, debug=False,
                     allowed_origins=None, check_origin=None,
                     session_expire_seconds=None,
                     session_cleanup_interval=None,
                     max_payload_size='200M',
                     **tornado_app_settings)

Source from the content-addressed store, hash-verified

291
292
293def path_deploy_http(base, port=0, host='',
294 index=True, static_dir=None,
295 cdn=True, debug=False,
296 allowed_origins=None, check_origin=None,
297 session_expire_seconds=None,
298 session_cleanup_interval=None,
299 max_payload_size='200M',
300 **tornado_app_settings):
301 """Deploy the PyWebIO applications from a directory.
302
303 The server communicates with the browser using HTTP protocol.
304
305 The ``base``, ``port``, ``host``, ``index``, ``static_dir`` arguments of ``path_deploy_http()``
306 have the same meaning as for :func:`pywebio.platform.path_deploy`
307
308 The rest arguments of ``path_deploy_http()`` have the same meaning as for :func:`pywebio.platform.tornado_http.start_server`
309 """
310 debug = Session.debug = os.environ.get('PYWEBIO_DEBUG', debug)
311
312 page.MAX_PAYLOAD_SIZE = max_payload_size = parse_file_size(max_payload_size)
313
314 gen = _path_deploy(base, port=port, host=host,
315 static_dir=static_dir, debug=debug,
316 max_payload_size=max_payload_size,
317 **tornado_app_settings)
318
319 cdn = cdn_validation(cdn, 'warn', stacklevel=3) # if CDN is not available, warn user and disable CDN
320
321 abs_base = next(gen)
322 index_func = {True: partial(default_index_page, base=abs_base), False: lambda p: '403 Forbidden'}.get(index, index)
323
324 def get_app(context: TornadoHttpContext):
325 reload = context.request_url_parameter('reload', None) is not None
326
327 type, res = get_app_from_path(context.get_path(), abs_base, index=index_func, reload=reload)
328 if type == 'error':
329 raise tornado.web.HTTPError(status_code=res)
330 elif type == 'html':
331 raise tornado.web.Finish(res)
332
333 app_name = context.request_url_parameter('app', 'index')
334 return res.get(app_name) or res['index']
335
336 class HttpPathDeployHandler(HttpHandler):
337 def get_cdn(self, context):
338 _cdn = super().get_cdn(context)
339 if not _cdn:
340 return LOCAL_STATIC_URL
341 return _cdn
342
343 handler = HttpPathDeployHandler(app_loader=get_app, cdn=cdn,
344 session_expire_seconds=session_expire_seconds,
345 session_cleanup_interval=session_cleanup_interval,
346 allowed_origins=allowed_origins,
347 check_origin=check_origin)
348
349 class ReqHandler(tornado.web.RequestHandler):
350 def options(self):

Callers

nothing calls this directly

Calls 7

parse_file_sizeFunction · 0.85
_path_deployFunction · 0.85
cdn_validationFunction · 0.85
sendMethod · 0.80
getMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…