序文 Foreword

Flaskを始める前に以下を読んでください。うまくいけば、この序文はこのプロジェクトの目的とゴールに関するいくつかの質問や、Flaskを使うべきときと使うべきではないときについて回答します。 Read this before you get started with Flask. This hopefully answers some questions about the purpose and goals of the project, and when you should or should not be using it.

「micro」の意味するところ What does "micro" mean?

「micro」は、webアプリケーション全体が単一のPythonファイルに収まることを必ずしも意味せず(しかしながらそれはある程度可能ですが)、Flaskの機能が不足していることも意味しません。microframeworkの「micro」は、Flaskが中核部分をシンプルでありつつ拡張可能なように保つことを目指していることを意味しています。Flaskは、例えばどのデータベースを使用するかといった、数多くの決定をあなたのためにしようとはしません。Flaskが決定したそれらの決定事項は、例えばどのテンプレート・エンジンを使うかといった決定は、容易に変更できます。(Flaskが決定していない)その他のすべてのことはあなた次第であり、従ってFlaskはあなたが必要とするもののすべてであって、必要としないものが何もないものになり得ます。 “Micro” does not mean that your whole web application has to fit into a single Python file (although it certainly can), nor does it mean that Flask is lacking in functionality. The "micro" in microframework means Flask aims to keep the core simple but extensible. Flask won't make many decisions for you, such as what database to use. Those decisions that it does make, such as what templating engine to use, are easy to change. Everything else is up to you, so that Flask can be everything you need and nothing you don't.

標準設定では、Flaskはデータベースを抽象化する階層、フォーム検証、または既に存在する異なるライブラリが処理可能なあらゆるものを含んでいません。代わりに、あたかもFlask自身にそのような機能性が実装されているかのように自分のアプリケーションへ追加する拡張性を、Flaskは提供します。数多くのFlask拡張がデータベース統合、フォーム検証、アップロード処理、多様なオープンの認証技術、その他を提供します。Flaskは「micro」かもしれませんが、多様なニーズに対して本番環境で使用する準備ができています。 By default, Flask does not include a database abstraction layer, form validation or anything else where different libraries already exist that can handle that. Instead, Flask supports extensions to add such functionality to your application as if it was implemented in Flask itself. Numerous extensions provide database integration, form validation, upload handling, various open authentication technologies, and more. Flask may be "micro", but it's ready for production use on a variety of needs.

設定および規約(Configuration and Conventions) Configuration and Conventions

Flaskには、理にかなった規定値を伴った数多くの設定値があり、始めるときのいくつかの規約(convention)があります。規約によって、テンプレートと静的ファイルが、それぞれtemplatesstaticという名前で、アプリケーションのPythonソースツリーないのサブディレクトリに格納されます。これらの名前は変更できますが、普通はその必要はなく、はじめるときは特にその必要はありません。 Flask has many configuration values, with sensible defaults, and a few conventions when getting started. By convention, templates and static files are stored in subdirectories within the application's Python source tree, with the names :file:`templates` and :file:`static` respectively. While this can be changed, you usually don't have to, especially when getting started.

Flaskを使った拡大(Growing with Flask) Growing with Flask

一度Flaskを起動して走らせたら、コミュニティの中で取得可能であり、本番環境用に自分のプロジェクトへ統合できる様々なFlask拡張が見つかるでしょう。FlaskのコアチームはFlask拡張をレビューし、承認されたFlask拡張(approved extensions)は将来のリリースでも壊れないことを保証します。(訳注: approved extensionsのリストは、この翻訳の作成時点で保守されなくなっています) Once you have Flask up and running, you'll find a variety of extensions available in the community to integrate your project for production. The Flask core team reviews extensions and ensures approved extensions do not break with future releases.

自分のコードベースが拡大するに応じて、自分のプロジェクトに適した設計上の決定を自由に下すことができます。FlaskはPythonが差し伸べる必要がある非常にシンプルな接合階層(glue layer)をできる限り提供し続けます。SQLAlchemyまたは他のデータベース用ツールで先進的なパターンを実装でき、リレーショナルでない永続データ(non-relational data persistence)を適宜導入でき、フレームワークと無関係にPythonのwebインタフェースであるWSGI用のツールを利用できます。 As your codebase grows, you are free to make the design decisions appropriate for your project. Flask will continue to provide a very simple glue layer to the best that Python has to offer. You can implement advanced patterns in SQLAlchemy or another database tool, introduce non-relational data persistence as appropriate, and take advantage of framework-agnostic tools built for WSGI, the Python web interface.

Flaskは振る舞いをカスタマイズするための数多くのフックを導入しています。さらなるカスタマイズが必要な場合は、Flaskクラスはサブクラスを利用しやすいように構築されています。もしそのことに関心がある場合は、巨大化(Becoming Big)章を調べてください。もしFlaskの設計原則に関して興味をひかれる場合は、Design Decisions in Flaskセクションを見てください。 Flask includes many hooks to customize its behavior. Should you need more customization, the Flask class is built for subclassing. If you are interested in that, check out the :ref:`becomingbig` chapter. If you are curious about the Flask design principles, head over to the section about :ref:`design`.

インストールクイックスタート、または経験のあるプログラマー向けの序文に続きます。 Continue to :ref:`installation`, the :ref:`quickstart`, or the :ref:`advanced_foreword`.