Extensions

Extensions are extra packages that add functionality to a Flaskapplication. For example, an extension might add support for sendingemail or connecting to a database. Some extensions add entire newframeworks to help build certain types of applications, like a REST API.

Finding Extensions

Flask extensions are usually named “Flask-Foo” or “Foo-Flask”. You cansearch PyPI for packages tagged with Framework :: Flask.

Using Extensions

Consult each extension’s documentation for installation, configuration,and usage instructions. Generally, extensions pull their ownconfiguration from app.config and arepassed an application instance during initialization. For example,an extension called “Flask-Foo” might be used like this:

  1. from flask_foo import Foo
  2.  
  3. foo = Foo()
  4.  
  5. app = Flask(__name__)
  6. app.config.update(
  7. FOO_BAR='baz',
  8. FOO_SPAM='eggs',
  9. )
  10.  
  11. foo.init_app(app)

Building Extensions

While the PyPI contains many Flask extensions, you maynot find an extension that fits your need. If this is the case, you cancreate your own. Read Flask Extension Development to develop your own Flaskextension.