Overview
Add a Flask adapter so users can install component-framework[flask] and use server-side components in Flask applications.
Required components
Per the Adapter Contract:
- Renderer subclass —
adapters/flask.py implementing the Renderer interface from core/renderer.py, using Jinja2 (Flask's built-in template engine)
- HTTP endpoint handler — a Flask view function (or Blueprint) that dispatches POST requests to the component registry
- Optional WebSocket handler — using
flask-sock or similar, following the same event protocol as the HTTP handler
- Optional extras group in
pyproject.toml:
[project.optional-dependencies]
flask = [
"flask>=3.0",
]
- Example — at least one working example in
examples/flask_example.py
- Docs — pdoc-compatible docstrings on all public symbols
Constitution gates
- Adapter code MUST NOT import from
core/ using framework-specific types
- The
[flask] extra MUST NOT pull in FastAPI, Django, or JinjaX
- All adapter tests MUST use
pytest.importorskip("flask")
Context
Part of the optional-dependencies refactor (Issue #4, PR implementing branch 001-optional-deps).
Flask and Litestar adapters were deferred to post-0.3.0.
Closes #4 (partially — Litestar tracked separately in #6)
Overview
Add a Flask adapter so users can install
component-framework[flask]and use server-side components in Flask applications.Required components
Per the Adapter Contract:
adapters/flask.pyimplementing theRendererinterface fromcore/renderer.py, using Jinja2 (Flask's built-in template engine)flask-sockor similar, following the same event protocol as the HTTP handlerpyproject.toml:examples/flask_example.pyConstitution gates
core/using framework-specific types[flask]extra MUST NOT pull in FastAPI, Django, or JinjaXpytest.importorskip("flask")Context
Part of the optional-dependencies refactor (Issue #4, PR implementing branch
001-optional-deps).Flask and Litestar adapters were deferred to post-0.3.0.
Closes #4 (partially — Litestar tracked separately in #6)