Skip to content

Add Flask adapter #5

@fsecada01

Description

@fsecada01

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:

  1. Renderer subclassadapters/flask.py implementing the Renderer interface from core/renderer.py, using Jinja2 (Flask's built-in template engine)
  2. HTTP endpoint handler — a Flask view function (or Blueprint) that dispatches POST requests to the component registry
  3. Optional WebSocket handler — using flask-sock or similar, following the same event protocol as the HTTP handler
  4. Optional extras group in pyproject.toml:
    [project.optional-dependencies]
    flask = [
        "flask>=3.0",
    ]
  5. Example — at least one working example in examples/flask_example.py
  6. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions