MCPcopy Create free account
hub / github.com/vercel/vercel / _setup_apps

Function _setup_apps

python/vercel-runtime/src/vercel_runtime/dev.py:391–429  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

389
390
391def _setup_apps() -> None:
392 global _asgi_user_app, _wsgi_user_app # noqa: PLW0603
393
394 module_name = os.environ["VERCEL_DEV_MODULE_NAME"]
395 entry_abs = os.environ["VERCEL_DEV_ENTRY_ABS"]
396 framework = os.environ["VERCEL_DEV_FRAMEWORK"]
397 variable_name = os.environ["VERCEL_DEV_VARIABLE_NAME"]
398
399 _setup_server_log_routing()
400 prepare_worker_environment()
401
402 mod = import_module(module_name, entry_abs)
403
404 if is_cron_service():
405 _asgi_user_app = bootstrap_cron_service_app(mod)
406 return
407
408 if is_worker_service():
409 worker_app = maybe_bootstrap_worker_service_app(mod)
410 if worker_app is not None:
411 _asgi_user_app = cast("ASGI", worker_app)
412 return
413
414 app_name, user_app = resolve_app(mod, module_name, variable_name)
415 try:
416 result = detect_app_type(user_app, module_name, app_name)
417 except RuntimeError:
418 _log.exception("could not detect application type")
419 sys.exit(1)
420
421 if result[0] == "asgi":
422 _asgi_user_app = result[1]
423 else:
424 wsgi_app = result[1]
425
426 if framework == "django":
427 wsgi_app = _wrap_django_static(wsgi_app)
428
429 _wsgi_user_app = wsgi_app
430
431
432def _wrap_django_static(app: WSGIApplication) -> WSGIApplication:

Callers 1

dev.pyFile · 0.85

Calls 11

import_moduleFunction · 0.90
is_cron_serviceFunction · 0.90
is_worker_serviceFunction · 0.90
resolve_appFunction · 0.90
detect_app_typeFunction · 0.90
_wrap_django_staticFunction · 0.85
exitMethod · 0.45

Tested by

no test coverage detected