diff --git a/flask/cli.py b/flask/cli.py index ad21d901..cdb7f094 100644 --- a/flask/cli.py +++ b/flask/cli.py @@ -47,17 +47,19 @@ def find_best_app(module): if len(matches) == 1: return matches[0] - # Search for app factory callable. - app_factory = getattr(module, 'create_app', None) - if app_factory is not None and callable(app_factory): - try: - app = app_factory() - if app is not None and isinstance(app, Flask): - return app - except TypeError: - raise NoAppException('Auto-detected a create_app() function in ' - 'module "%s", but could not call it without ' - 'specifying arguments.' % module.__name__) + # Search for app factory callables. + for attr_name in 'create_app', 'make_app': + app_factory = getattr(module, attr_name, None) + if app_factory is not None and callable(app_factory): + try: + app = app_factory() + if app is not None and isinstance(app, Flask): + return app + except TypeError: + raise NoAppException('Auto-detected "%s()" in module "%s", ' + 'but could not call it without ' + 'specifying arguments.' + % (attr_name, module.__name__)) raise NoAppException('Failed to find application in module "%s". Are ' 'you sure it contains a Flask application? Maybe ' diff --git a/tests/test_cli.py b/tests/test_cli.py index 53c320eb..bbb6fe58 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -58,6 +58,13 @@ def test_find_best_app(test_apps): assert isinstance(find_best_app(Module), Flask) assert find_best_app(Module).name == 'appname' + class Module: + @staticmethod + def make_app(): + return Flask('appname') + assert isinstance(find_best_app(Module), Flask) + assert find_best_app(Module).name == 'appname' + class Module: myapp = Flask('appname1') @staticmethod