Home / Class/ Flask Class — flask Architecture

Flask Class — flask Architecture

Architecture documentation for the Flask class in app.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5["Flask"]
  38f6d4a2_834e_2acd_e1b6_f45c58079ccd["App"]
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 -->|extends| 38f6d4a2_834e_2acd_e1b6_f45c58079ccd
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5["Flask"]
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 -->|extends| 9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5
  86817dcd_97b5_9a9f_aee8_5fa78b4cecc9["AppContext"]
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 -->|extends| 86817dcd_97b5_9a9f_aee8_5fa78b4cecc9
  d37e98da_a97c_3126_ebd5_0a54e0ea9b29["Response"]
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 -->|extends| d37e98da_a97c_3126_ebd5_0a54e0ea9b29
  9612cfdd_2178_92c0_2ed7_16ebb0c72901["app.py"]
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 -->|defined in| 9612cfdd_2178_92c0_2ed7_16ebb0c72901
  9ecf8228_23ee_83b6_506a_89e897629e5e["__init_subclass__()"]
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 -->|method| 9ecf8228_23ee_83b6_506a_89e897629e5e
  21993c25_d44a_bd35_e477_2d16af1e7237["__init__()"]
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 -->|method| 21993c25_d44a_bd35_e477_2d16af1e7237
  b9ae92e8_aac9_2239_118e_1bf35728c3f1["get_send_file_max_age()"]
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 -->|method| b9ae92e8_aac9_2239_118e_1bf35728c3f1
  0961f519_f2ef_dd1b_2adf_c3eaabdb53a7["send_static_file()"]
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 -->|method| 0961f519_f2ef_dd1b_2adf_c3eaabdb53a7
  c92a3a8a_766d_75a0_8dd5_ab00df390e5d["open_resource()"]
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 -->|method| c92a3a8a_766d_75a0_8dd5_ab00df390e5d
  5a6d3d45_9ce0_b4dc_5aad_19ba0e2d3bd8["open_instance_resource()"]
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 -->|method| 5a6d3d45_9ce0_b4dc_5aad_19ba0e2d3bd8
  a0656ef1_9a0d_d80d_c641_a8449df792e7["create_jinja_environment()"]
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 -->|method| a0656ef1_9a0d_d80d_c641_a8449df792e7
  50282238_729d_4729_21d4_c290921ffa61["create_url_adapter()"]
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 -->|method| 50282238_729d_4729_21d4_c290921ffa61
  ed42e052_3b19_c965_f4bb_2b6c30bb3cbc["raise_routing_exception()"]
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 -->|method| ed42e052_3b19_c965_f4bb_2b6c30bb3cbc
  8c4a599b_81bd_7179_af9c_5ae61d56dc9d["update_template_context()"]
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 -->|method| 8c4a599b_81bd_7179_af9c_5ae61d56dc9d

Relationship Graph

Source Code

src/flask/app.py lines 108–1606

class Flask(App):
    """The flask object implements a WSGI application and acts as the central
    object.  It is passed the name of the module or package of the
    application.  Once it is created it will act as a central registry for
    the view functions, the URL rules, template configuration and much more.

    The name of the package is used to resolve resources from inside the
    package or the folder the module is contained in depending on if the
    package parameter resolves to an actual python package (a folder with
    an :file:`__init__.py` file inside) or a standard module (just a ``.py`` file).

    For more information about resource loading, see :func:`open_resource`.

    Usually you create a :class:`Flask` instance in your main module or
    in the :file:`__init__.py` file of your package like this::

        from flask import Flask
        app = Flask(__name__)

    .. admonition:: About the First Parameter

        The idea of the first parameter is to give Flask an idea of what
        belongs to your application.  This name is used to find resources
        on the filesystem, can be used by extensions to improve debugging
        information and a lot more.

        So it's important what you provide there.  If you are using a single
        module, `__name__` is always the correct value.  If you however are
        using a package, it's usually recommended to hardcode the name of
        your package there.

        For example if your application is defined in :file:`yourapplication/app.py`
        you should create it with one of the two versions below::

            app = Flask('yourapplication')
            app = Flask(__name__.split('.')[0])

        Why is that?  The application will work even with `__name__`, thanks
        to how resources are looked up.  However it will make debugging more
        painful.  Certain extensions can make assumptions based on the
        import name of your application.  For example the Flask-SQLAlchemy
        extension will look for the code in your application that triggered
        an SQL query in debug mode.  If the import name is not properly set
        up, that debugging information is lost.  (For example it would only
        pick up SQL queries in `yourapplication.app` and not
        `yourapplication.views.frontend`)

    .. versionadded:: 0.7
       The `static_url_path`, `static_folder`, and `template_folder`
       parameters were added.

    .. versionadded:: 0.8
       The `instance_path` and `instance_relative_config` parameters were
       added.

    .. versionadded:: 0.11
       The `root_path` parameter was added.

    .. versionadded:: 1.0
       The ``host_matching`` and ``static_host`` parameters were added.

    .. versionadded:: 1.0
       The ``subdomain_matching`` parameter was added. Subdomain
       matching needs to be enabled manually now. Setting
       :data:`SERVER_NAME` does not implicitly enable it.

    :param import_name: the name of the application package
    :param static_url_path: can be used to specify a different path for the
                            static files on the web.  Defaults to the name
                            of the `static_folder` folder.
    :param static_folder: The folder with static files that is served at
        ``static_url_path``. Relative to the application ``root_path``
        or an absolute path. Defaults to ``'static'``.
    :param static_host: the host to use when adding the static route.
        Defaults to None. Required when using ``host_matching=True``
        with a ``static_folder`` configured.
    :param host_matching: set ``url_map.host_matching`` attribute.
        Defaults to False.
    :param subdomain_matching: consider the subdomain relative to
        :data:`SERVER_NAME` when matching routes. Defaults to False.
    :param template_folder: the folder that contains the templates that should

Defined In

Frequently Asked Questions

What is the Flask class?
Flask is a class in the flask codebase, defined in src/flask/app.py.
Where is Flask defined?
Flask is defined in src/flask/app.py at line 108.
What does Flask extend?
Flask extends App, Flask, AppContext, Response.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free