def export(
    zipping: bool = True,
    frontend: bool = True,
    backend: bool = True,
    zip_dest_dir: str = str(Path.cwd()),
    upload_db_file: bool = False,
    api_url: str | None = None,
    deploy_url: str | None = None,
    env: constants.Env = constants.Env.PROD,
    loglevel: constants.LogLevel = console._LOG_LEVEL,
):
    """Export the app to a zip file.

    Args:
        zipping: Whether to zip the exported app. Defaults to True.
        frontend: Whether to export the frontend. Defaults to True.
        backend: Whether to export the backend. Defaults to True.
        zip_dest_dir: The directory to export the zip file to. Defaults to os.getcwd().
        upload_db_file: Whether to upload the database file. Defaults to False.
        api_url: The API URL to use. Defaults to None.
        deploy_url: The deploy URL to use. Defaults to None.
        env: The environment to use. Defaults to constants.Env.PROD.
        loglevel: The log level to use. Defaults to console._LOG_LEVEL.
    """
    config = get_config()

    # Set the log level.
    console.set_log_level(loglevel)

    # Set env mode in the environment
    environment.REFLEX_ENV_MODE.set(env)

    # Override the config url values if provided.
    if api_url is not None:
        config._set_persistent(api_url=str(api_url))
        console.debug(f"overriding API URL: {config.api_url}")
    if deploy_url is not None:
        config._set_persistent(deploy_url=str(deploy_url))
        console.debug(f"overriding deploy URL: {config.deploy_url}")

    # Show system info
    exec.output_system_info()

    # Compile the app in production mode and export it.
    console.rule("[bold]Compiling production app and preparing for export.")

    if frontend:
        # Ensure module can be imported and app.compile() is called.
        prerequisites.get_compiled_app(export=True)
        # Set up .web directory and install frontend dependencies.
        build.setup_frontend(Path.cwd())

    # Build the static app.
    if frontend:
        build.build(deploy_url=config.deploy_url, for_export=True)

    # Zip up the app.
    if zipping:
        build.zip_app(
            frontend=frontend,
            backend=backend,
            zip_dest_dir=zip_dest_dir,
            upload_db_file=upload_db_file,
        )

    # Post a telemetry event.
    telemetry.send("export")
Export the app to a zip file.

    Args:
        zipping: Whether to zip the exported app. Defaults to True.
        frontend: Whether to export the frontend. Defaults to True.
        backend: Whether to export the backend. Defaults to True.
        zip_dest_dir: The directory to export the zip file to. Defaults to os.getcwd().
        upload_db_file: Whether to upload the database file. Defaults to False.
        api_url: The API URL to use. Defaults to None.
        deploy_url: The deploy URL to use. Defaults to None.
        env: The environment to use. Defaults to constants.Env.PROD.
        loglevel: The log level to use. Defaults to console._LOG_LEVEL.
    
reflex/utils/export.py