Flask拡張(Extensions) Extensions

Flask拡張はFlaskアプリケーションに機能性を追加する追加パッケージです。例えば、Flask拡張は電子メールの送信やデータベースへの接続のサポートを追加するかもしれません。Flask拡張のなかには、REST APIのような、ある種のアプリケーションの構築を手助けする新しいフレームワーク全体を追加するものがあります。 Extensions are extra packages that add functionality to a Flask application. For example, an extension might add support for sending email or connecting to a database. Some extensions add entire new frameworks to help build certain types of applications, like a REST API.

Flask拡張の探し出し Finding Extensions

Flask拡張は普通「Flask-Foo」または「Foo-Flask」と名付けられています。PyPIでFramework :: Flaskとタグ付けされているパッケージを探すことができます。 Flask extensions are usually named "Flask-Foo" or "Foo-Flask". You can search PyPI for packages tagged with `Framework :: Flask <pypi_>`_.

Flask拡張の使用方法 Using Extensions

インストール、設定、使用手順については各Flask拡張のドキュメントを調査してください。概して、Flask拡張は自分の設定をapp.configから引き出し、アプリケーションのインスタンスを初期化中に渡されます。例えば、「Flask-Foo」というFlask拡張は以下のようなものかもしれません: Consult each extension's documentation for installation, configuration, and usage instructions. Generally, extensions pull their own configuration from :attr:`app.config <flask.Flask.config>` and are passed an application instance during initialization. For example, an extension called "Flask-Foo" might be used like this::

from flask_foo import Foo

foo = Foo()

app = Flask(__name__)
app.config.update(
    FOO_BAR='baz',
    FOO_SPAM='eggs',
)

foo.init_app(app)

Flask拡張の構築 Building Extensions

PyPIは多くのFlask拡張を含んでいますが、自分のニーズに合ったものが見つからないかもしれません。そのような場合には、自分独自のものを作成し、他の人も同様に使えるよう公開できます。自分独自のFlask拡張を開発するにはFlask拡張の開発を読んでください。 While `PyPI <pypi_>`_ contains many Flask extensions, you may not find an extension that fits your need. If this is the case, you can create your own, and publish it for others to use as well. Read :doc:`extensiondev` to develop your own Flask extension.