Use from a Flask application factory. Registers a before_request
callback that calls snitchbot.init() exactly once per worker process
on the first incoming request. Subsequent requests are no-ops.
Signature
def init_app(app, *, service: str, **init_kwargs: Any) -> None
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
app | flask.Flask | The Flask application returned by your factory. | required |
service | str | Forwarded to snitchbot.init as the first positional argument. | required |
**init_kwargs | Any | Forwarded verbatim to snitchbot.init (e.g. role="web", live_dashboard=False). | — |
Example
from flask import Flask
from snitchbot.integrations.flask import init_app, install
def create_app() -> Flask:
app = Flask(__name__)
init_app(app, service="orders-api", role="web")
install(app)
return app
Related
init()— every kwarg here forwards toinit().- Guide: Flask integration.