Skip to main content

locate_app

Imports a specified module and attempts to locate a Flask application instance within it, either by searching for a specific name or using a discovery heuristic. It raises a NoAppException if the module cannot be imported or the application cannot be found, unless configured otherwise.

def locate_app(
module_name: str,
app_name: str | None,
raise_if_not_found: bool = True
) - > Flask | None

Attempts to import a module and locate a Flask application instance within it, either by a specific name or by searching for the best candidate.

Parameters

NameTypeDescription
module_namestrThe fully qualified name of the Python module to import and search for the application.
app_name`strNone`
raise_if_not_foundbool = TrueDetermines whether to raise a NoAppException or return None if the specified module cannot be imported.

Returns

TypeDescription
`FlaskNone`