# flask

URL: /kida/api/contrib/flask/
Section: contrib
Description: Flask integration for Kida.

Provides ``init_kida`` to replace Flask's default Jinja2 engine with Kida.

Usage::

    from flask import Flask
    from kida.contrib.flask import init_kida

    app = Flask(__name__)
    kida_env = init_kida(app)

    @app.route("/")
    def index():
        return render_template("index.html", title="Home")

---

> For a complete page index, fetch /kida/llms.txt.

Open LLM text
(/kida/api/contrib/flask/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcontrib%2Fflask%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcontrib%2Fflask%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcontrib%2Fflask%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcontrib%2Fflask%2Findex.txt)

Module

#
`contrib.flask`

Flask integration for Kida.

Provides`init_kida`to replace Flask's default Jinja2 engine with Kida.

Usage::

```
from flask import Flask
from kida.contrib.flask import init_kida

app = Flask(__name__)
kida_env = init_kida(app)

@app.route("/")
def index():
    return render_template("index.html", title="Home")
```

2Functions

## Functions

`init_kida`

3

`Environment`

▼

Initialize Kida as the template engine for a Flask app.

Replaces Flask's defau…

`def init_kida(app: Any, *, template_folder: str | None = None, **env_kwargs: Any) -> Environment`

Initialize Kida as the template engine for a Flask app.

Replaces Flask's default Jinja2 environment with Kida. Templates
are loaded from the app's template folder.

##### Parameters

Name
Type
Description

`app`
`Any`

Flask application instance.

`template_folder`
`str | None`

Override for template directory. Defaults to`app.template_folder`. **env_kwargs: Additional kwargs passed to Kida Environment.

Default:`None`

`**env_kwargs`
`Any`

##### Returns

`Environment`

`render_template`

2

`str`

▼

Render a template using the current app's Kida environment.

Call this from a F…

`def render_template(template_name: str, **context: Any) -> str`

Render a template using the current app's Kida environment.

Call this from a Flask request context. Requires`init_kida()`
to have been called on the app.

##### Parameters

Name
Type
Description

`template_name`
`str`

Name of the template to render. **context: Template context variables.

`**context`
`Any`

##### Returns

`str`
