|
|
|
@ -37,7 +37,7 @@ def find_best_app(module):
|
|
|
|
|
# Search for the most common names first. |
|
|
|
|
for attr_name in 'app', 'application': |
|
|
|
|
app = getattr(module, attr_name, None) |
|
|
|
|
if app is not None and isinstance(app, Flask): |
|
|
|
|
if isinstance(app, Flask): |
|
|
|
|
return app |
|
|
|
|
|
|
|
|
|
# Otherwise find the only object that is a Flask instance. |
|
|
|
@ -50,21 +50,23 @@ def find_best_app(module):
|
|
|
|
|
# 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): |
|
|
|
|
if callable(app_factory): |
|
|
|
|
try: |
|
|
|
|
app = app_factory() |
|
|
|
|
if app is not None and isinstance(app, Flask): |
|
|
|
|
if 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 ' |
|
|
|
|
'you wrapped it in a WSGI middleware or you are ' |
|
|
|
|
'using a factory function.' % module.__name__) |
|
|
|
|
raise NoAppException( |
|
|
|
|
'Auto-detected "{callable}()" in module "{module}", but ' |
|
|
|
|
'could not call it without specifying arguments.' |
|
|
|
|
.format(callable=attr_name, |
|
|
|
|
module=module.__name__)) |
|
|
|
|
|
|
|
|
|
raise NoAppException( |
|
|
|
|
'Failed to find application in module "{module}". Are you sure ' |
|
|
|
|
'it contains a Flask application? Maybe you wrapped it in a WSGI ' |
|
|
|
|
'middleware or you are using a factory function.' |
|
|
|
|
.format(module=module.__name__)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def prepare_exec_for_file(filename): |
|
|
|
|