()
| 389 | |
| 390 | |
| 391 | def _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 | |
| 432 | def _wrap_django_static(app: WSGIApplication) -> WSGIApplication: |
no test coverage detected