"""API server entry point."""importloggingimportosfrompathlibimportPathfromconnexionimportFlaskAppfromfocaimportFocalogger=logging.getLogger(__name__)
[docs]definit_app()->FlaskApp:"""Initialize and return the FOCA app. This function initializes the FOCA app by loading the configuration from the environment variable `TESK_FOCA_CONFIG_PATH` if set, or from the default path if not. It raises a `FileNotFoundError` if the configuration file is not found. Returns: A Connexion application instance. Raises: FileNotFoundError: If the configuration file is not found. """# Determine the configuration pathifconfig_path_env:=os.getenv("TESK_FOCA_CONFIG_PATH"):config_path=Path(config_path_env).resolve()else:config_path=(Path(__file__).parents[1]/"deployment"/"config.yaml").resolve()# Check if the configuration file existsifnotconfig_path.exists():raiseFileNotFoundError(f"Config file not found at: {config_path}")foca=Foca(config_file=config_path,custom_config_model="tesk.custom_config.CustomConfig",)returnfoca.create_app()