Flask App Initialization
deployless automatically uses your create_app() factory to initialize each Lambda — no extra configuration needed.
Zero-config: app factory auto-detection
If your project has a create_app() function in app/__init__.py, the generated bootstrap calls it directly:
def create_app() -> Flask:
app = Flask(__name__)
CORS(app, origins=settings.CORS_ORIGINS)
register_error_handlers(app)
app.register_blueprint(todo_bp)
return app
The generated bootstrap:
try:
from app import create_app as _deployless_factory
flask_app = _deployless_factory() # CORS, error handlers, etc. all applied
del _deployless_factory
except (ImportError, AttributeError) as _e:
# Fallback: manual bootstrap
...
For multi-feature projects, deployless generates minimal stubs for other features so create_app() can import all blueprints without errors:
.dist/TodoFunction/
app/
__init__.py ← real (with create_app)
features/
todo/ ← real code
auth/routes.py ← stub (empty Blueprint, ~5 lines)
user/routes.py ← stub (empty Blueprint, ~5 lines)
shared/
Fallback: manual bootstrap
If create_app() is not found or fails to import, deployless falls back to manual bootstrap, registering blueprints directly. In this case, cors: and init_app: from deployless.yaml are used.
A warning is printed to stderr:
[deployless] create_app() unavailable (...). Using manual bootstrap.
init_app (legacy / override)
init_app in deployless.yaml is the explicit alternative for projects without an app factory. It is only applied in the fallback path.
init_app:
- app.shared.errors.register_error_handlers
- app.shared.middleware.register_middleware
Each entry is a dotted module.function path. deployless imports and calls function(flask_app):
from app.shared.errors import register_error_handlers
register_error_handlers(flask_app)
Validation
| Code | Rule |
|---|---|
| E31 | Each init_app entry must be a string in module.function format |