docstring_tokens stringlengths 0 76.5k | code_tokens stringlengths 75 1.81M | label_window listlengths 4 2.12k | html_url stringlengths 74 116 | file_name stringlengths 3 311 |
|---|---|---|---|---|
cv = Condition() | <mask> def test_before_first_request_functions_concurrent(self):
<mask> got = []
<mask> app = flask.Flask(__name__)
<mask> @app.before_first_request
<mask> def foo():
<mask> with cv:
<mask> cv.wait()
<mask> got.append(42)
<mask> ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/75f2af7a6afdf620d7afdccee876b06f8c39373b | flask/testsuite/basic.py |
with cv:
cv.wait() | <mask> got = []
<mask> app = flask.Flask(__name__)
<mask> @app.before_first_request
<mask> def foo():
<mask> sleep(1)
<mask> got.append(42)
<mask> c = app.test_client()
<mask> def get_and_assert():
<mask> c.get("/")
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/75f2af7a6afdf620d7afdccee876b06f8c39373b | flask/testsuite/basic.py |
with cv:
cv.notify() | <mask> c = app.test_client()
<mask> def get_and_assert():
<mask> c.get("/")
<mask> self.assert_equal(got, [42])
<mask> t = Thread(target=get_and_assert)
<mask> t.start()
<mask> get_and_assert()
<mask> t.join()
</s> Use a condition variable... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/75f2af7a6afdf620d7afdccee876b06f8c39373b | flask/testsuite/basic.py |
- View functions can return generators directly instead of wrapping
them in a ``Response``. :pr:`4629` | <mask> - ``SessionInterface.get_expiration_time`` uses a timezone-aware
<mask> value. :pr:`4645`
<mask>
<mask>
<mask> Version 2.1.3
<mask> -------------
<mask>
</s> view functions can return generators as responses directly </s> remove ResponseValue = t.Union["Response", str, bytes, t.Dict[str, t.Any]]... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/762382e436062183b1e1fa6f3bda594090a452e7 | CHANGES.rst |
from collections.abc import Iterator as _abc_Iterator | <mask> import sys
<mask> import typing as t
<mask> import weakref
<mask> from datetime import timedelta
<mask> from itertools import chain
<mask> from threading import Lock
<mask> from types import TracebackType
<mask>
<mask> import click
</s> view functions can return generators as responses directly </s> r... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/762382e436062183b1e1fa6f3bda594090a452e7 | src/flask/app.py |
``generator`` or ``iterator``
A generator that returns ``str`` or ``bytes`` to be
streamed as the response.
| <mask>
<mask> ``dict``
<mask> A dictionary that will be jsonify'd before being returned.
<mask>
<mask> ``tuple``
<mask> Either ``(body, status, headers)``, ``(body, status)``, or
<mask> ``(body, headers)``, where ``body`` is any of the oth... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/762382e436062183b1e1fa6f3bda594090a452e7 | src/flask/app.py |
ResponseValue = t.Union[
"Response", str, bytes, t.Dict[str, t.Any], t.Iterator[str], t.Iterator[bytes]
] | <mask> from werkzeug.datastructures import Headers # noqa: F401
<mask> from werkzeug.wrappers import Response # noqa: F401
<mask>
<mask> # The possible types that are directly convertible or are a Response object.
<mask> ResponseValue = t.Union["Response", str, bytes, t.Dict[str, t.Any]]
<mask>
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/762382e436062183b1e1fa6f3bda594090a452e7 | src/flask/typing.py |
@app.route("/template")
def return_template_stream() -> t.Iterator[str]:
return stream_template("index.html", name="Hello")
| <mask> return render_template("index.html", name=name)
<mask>
<mask>
<mask> class RenderTemplateView(View):
<mask> def __init__(self: RenderTemplateView, template_name: str) -> None:
<mask> self.template_name = template_name
<mask>
<mask> def dispatch_request(self: RenderTemplateView) -> ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/762382e436062183b1e1fa6f3bda594090a452e7 | tests/typing/typing_route.py |
Version 0.8.1
-------------
Bugfix release, release date to be decided
| <mask> ===============
<mask>
<mask> Here you can see the full list of changes between each Flask release.
<mask>
<mask> Version 0.8
<mask> -----------
<mask>
<mask> Released on September 29th 2011, codename Rakija
<mask>
<mask> - Refactored session support into a session interface so that
</s> Prepare f... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/766522cb587850f643f3bb6cb011735ae6a98510 | CHANGES |
__version__ = '0.8.1-dev' | <mask> :copyright: (c) 2011 by Armin Ronacher.
<mask> :license: BSD, see LICENSE for more details.
<mask> """
<mask>
<mask> __version__ = '0.8'
<mask>
<mask> # utilities we import from Werkzeug and Jinja2 that are unused
<mask> # in the module but are exported as public interface.
<mask> from werkzeu... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/766522cb587850f643f3bb6cb011735ae6a98510 | flask/__init__.py |
version='0.8.1-dev', | <mask> print "No problems found in sourcecode."
<mask>
<mask> setup(
<mask> name='Flask',
<mask> version='0.8',
<mask> url='http://github.com/mitsuhiko/flask/',
<mask> license='BSD',
<mask> author='Armin Ronacher',
<mask> author_email='armin.ronacher@active-4.com',
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/766522cb587850f643f3bb6cb011735ae6a98510 | setup.py |
browsers. | <mask> Released 2016-05-29, codename Absinthe
<mask>
<mask> - Added support to serializing top-level arrays to
<mask> :func:`flask.jsonify`. This introduces a security risk in ancient
<mask> browsers. See :ref:`json-security` for details.
<mask> - Added before_render_template signal.
<mask> - Adde... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | CHANGES.rst |
limit the impact an attacker can do if the secret key leaks. | <mask>
<mask> Released 2013-06-13, codename Limoncello
<mask>
<mask> - Changed default cookie serialization format from pickle to JSON to
<mask> limit the impact an attacker can do if the secret key leaks. See
<mask> :ref:`upgrading-to-010` for more information.
<mask> - Added ``template_test`` met... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | CHANGES.rst |
that might expect ``flask.json.dumps`` to return bytes by default. | <mask> imported templates by default.
<mask> - Added an option to generate non-ascii encoded JSON which should
<mask> result in less bytes being transmitted over the network. It's
<mask> disabled by default to not cause confusion with existing libraries
<mask> that might expect ``flask.json.dumps... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | CHANGES.rst |
etc. | <mask> modules are located but also an instance path which is the
<mask> designated place to drop files that are modified at runtime (uploads
<mask> etc.). Also this is conceptually only instance depending and outside
<mask> version control so it's the perfect place to put configuration files
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | CHANGES.rst |
longer executed when an exception is raised. | <mask> - Implemented a silent flag for ``config.from_pyfile``.
<mask> - Added ``teardown_request`` decorator, for functions that should run
<mask> at the end of a request regardless of whether an exception occurred.
<mask> Also the behavior for ``after_request`` was changed. It's now no
<mask> long... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | CHANGES.rst |
- Implemented generic class-based views. | <mask> can provide custom error messages from a central hub for certain
<mask> errors that might occur during request processing (for instance
<mask> database connection errors, timeouts from remote resources etc.).
<mask> - Blueprints can provide blueprint specific error handlers.
<mask> - Impleme... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | CHANGES.rst |
combinations of Python and dependencies. If you don't have a Python
version installed, it will be skipped with a warning message at the end.
Run:: | <mask> depends on which part of Flask you're working on. Travis-CI will run the full
<mask> suite when you submit your pull request.
<mask>
<mask> The full test suite takes a long time to run because it tests multiple
<mask> combinations of Python and dependencies. You need to have Python 2.7, 3.4,
<mask> 3.5, 3... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | CONTRIBUTING.rst |
application. It should be a long random ``bytes`` or ``str``. For
example, copy the output of this to your config:: | <mask> .. py:data:: SECRET_KEY
<mask>
<mask> A secret key that will be used for securely signing the session cookie
<mask> and can be used for any other security related needs by extensions or your
<mask> application. It should be a long random string of bytes, although unicode
<mask> is accepted... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/config.rst |
Serialize objects to ASCII-encoded JSON. If this is disabled, the
JSON returned from ``jsonify`` will contain Unicode characters. This
has security implications when rendering the JSON into JavaScript in
templates, and should typically remain enabled. | <mask> Default: ``None``
<mask>
<mask> .. py:data:: JSON_AS_ASCII
<mask>
<mask> Serialize objects to ASCII-encoded JSON. If this is disabled, the JSON
<mask> will be returned as a Unicode string, or encoded as ``UTF-8`` by
<mask> ``jsonify``. This has security implications when rendering the JS... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/config.rst |
$PREFIX/lib/pythonX.Y/site-packages/myapp | <mask> /instance
<mask>
<mask> - Installed module or package::
<mask>
<mask> $PREFIX/lib/python2.X/site-packages/myapp
<mask> $PREFIX/var/myapp-instance
<mask>
<mask> ``$PREFIX`` is the prefix of your Python installation. This can be
<mask> ``/usr`` or the path to your vir... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/config.rst |
<mask> you have to modify your ``.wsgi`` file slightly.
<mask>
<mask> Add the following lines to the top of your ``.wsgi`` file::
<mask>
<mask> activate_this = '/path/to/env/bin/activate_this.py'
<mask> execfile(activate_this, dict(__file__=activate_this))
<mask>
<mask> For Python 3 add the following... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/deploying/mod_wsgi.rst | |
But that's about where similarities end. Jinja2 for example has an
extensive filter system, a certain way to do template inheritance,
support for reusable blocks (macros) that can be used from inside
templates and also from Python code, supports iterative template
rendering, configurable syntax and more. On the other h... | <mask> has a certain understanding about how things work. On the surface they
<mask> all work the same: you tell the engine to evaluate a template with a set
<mask> of variables and take the return value as string.
<mask>
<mask> But that's about where similarities end. Jinja2 for example has an
<mask> extensiv... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/design.rst |
<mask>
<mask> design
<mask> htmlfaq
<mask> security
<mask> unicode
<mask> extensiondev
<mask> styleguide
<mask> upgrading
<mask> changelog
<mask> license
</s> remove Python 2 from docs </s> remove styleguide
upgrading
</s> add </s> remove application. It should be a lo... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/index.rst | |
<mask> htmlfaq
<mask> security
<mask> unicode
<mask> extensiondev
<mask> styleguide
<mask> upgrading
<mask> changelog
<mask> license
<mask> contributing
</s> remove Python 2 from docs </s> remove unicode
</s> add </s> remove application. It should be a long random string of... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/index.rst | |
We recommend using the latest version of Python. Flask supports Python
3.6 and newer.
| <mask>
<mask> Python Version
<mask> --------------
<mask>
<mask> We recommend using the latest version of Python 3. Flask supports Python 3.5
<mask> and newer, Python 2.7, and PyPy.
<mask>
<mask> Dependencies
<mask> ------------
<mask>
<mask> These distributions will be installed automatically when insta... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/installation.rst |
Python comes bundled with the :mod:`venv` module to create virtual
environments. | <mask> Virtual environments are independent groups of Python libraries, one for each
<mask> project. Packages installed for one project will not affect other projects or
<mask> the operating system's packages.
<mask>
<mask> Python 3 comes bundled with the :mod:`venv` module to create virtual
<mask> environments.... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/installation.rst |
<mask> to the next section.
<mask>
<mask> If you're using Python 2, see :ref:`install-install-virtualenv` first.
<mask>
<mask> .. _install-create-env:
<mask>
<mask> Create an environment
<mask> ~~~~~~~~~~~~~~~~~~~~~
<mask>
<mask> Create a project folder and a :file:`venv` folder within:
</s> remove Pytho... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/installation.rst | |
<mask> .. code-block:: bat
<mask>
<mask> $ py -3 -m venv venv
<mask>
<mask> If you needed to install virtualenv because you are using Python 2, use
<mask> the following command instead:
<mask>
<mask> .. code-block:: sh
<mask>
<mask> $ python2 -m virtualenv venv
<mask>
<mask> On Windows:
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/installation.rst | |
Your shell prompt will change to show the name of the activated
environment.
| <mask> .. code-block:: bat
<mask>
<mask> > venv\Scripts\activate
<mask>
<mask> Your shell prompt will change to show the name of the activated environment.
<mask>
<mask> Install Flask
<mask> -------------
<mask>
<mask> Within the activated environment, use the following command to install Flask:
</s>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/installation.rst |
Within the activated environment, use the following command to install
Flask: | <mask>
<mask> Install Flask
<mask> -------------
<mask>
<mask> Within the activated environment, use the following command to install Flask:
<mask>
<mask> .. code-block:: sh
<mask>
<mask> $ pip install Flask
<mask>
</s> remove Python 2 from docs </s> remove Your shell prompt will change to show the ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/installation.rst |
<mask> $ pip install Flask
<mask>
<mask> Flask is now installed. Check out the :doc:`/quickstart` or go to the
<mask> :doc:`Documentation Overview </index>`.
<mask>
<mask> Living on the edge
<mask> ~~~~~~~~~~~~~~~~~~
<mask>
<mask> If you want to work with the latest Flask code before it's released, inst... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"re... | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/installation.rst | |
<mask> declare an "entry point" that another package can hook into to extend the
<mask> other package.
<mask> - **installation manager**: :command:`pip` can install other libraries for you.
<mask>
<mask> If you have Python 2 (>=2.7.9) or Python 3 (>=3.4) installed from python.org,
<mask> you will already hav... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/patterns/distribute.rst | |
engine = create_engine('sqlite:////tmp/test.db') | <mask> from sqlalchemy import create_engine
<mask> from sqlalchemy.orm import scoped_session, sessionmaker
<mask> from sqlalchemy.ext.declarative import declarative_base
<mask>
<mask> engine = create_engine('sqlite:////tmp/test.db', convert_unicode=True)
<mask> db_session = scoped_session(ses... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/patterns/sqlalchemy.rst |
engine = create_engine('sqlite:////tmp/test.db') | <mask>
<mask> from sqlalchemy import create_engine, MetaData
<mask> from sqlalchemy.orm import scoped_session, sessionmaker
<mask>
<mask> engine = create_engine('sqlite:////tmp/test.db', convert_unicode=True)
<mask> metadata = MetaData()
<mask> db_session = scoped_session(sessionmaker(autoc... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/patterns/sqlalchemy.rst |
engine = create_engine('sqlite:////tmp/test.db') | <mask> you basically only need the engine::
<mask>
<mask> from sqlalchemy import create_engine, MetaData, Table
<mask>
<mask> engine = create_engine('sqlite:////tmp/test.db', convert_unicode=True)
<mask> metadata = MetaData(bind=engine)
<mask>
<mask> Then you can either declare the tables in your... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/patterns/sqlalchemy.rst |
the input element. Note that WTForms returns standard Python strings,
so we have to tell Jinja2 that this data is already HTML-escaped with
the ``|safe`` filter. | <mask> This macro accepts a couple of keyword arguments that are forwarded to
<mask> WTForm's field function, which renders the field for us. The keyword
<mask> arguments will be inserted as HTML attributes. So, for example, you can
<mask> call ``render_field(form.username, class='username')`` to add a class to
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/patterns/wtforms.rst |
3. URL building handles escaping of special characters transparently. | <mask>
<mask> 1. Reversing is often more descriptive than hard-coding the URLs.
<mask> 2. You can change your URLs in one go instead of needing to remember to
<mask> manually change hard-coded URLs.
<mask> 3. URL building handles escaping of special characters and Unicode data
<mask> transparently.
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/quickstart.rst |
``data``. Bytes must be compared to bytes. If you want to compare text,
use :meth:`get_data(as_text=True) <werkzeug.wrappers.BaseResponse.get_data>` | <mask> URL when the register view redirects to the login view.
<mask>
<mask> :attr:`~Response.data` contains the body of the response as bytes. If
<mask> you expect a certain value to render on the page, check that it's in
<mask> ``data``. Bytes must be compared to bytes. If you want to compare
<mask> Unicode te... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | docs/tutorial/tests.rst |
:param root_path: The path to the root of the application files.
This should only be set manually when it can't be detected
automatically, such as for namespace packages. | <mask> :param instance_relative_config: if set to ``True`` relative filenames
<mask> for loading the config are assumed to
<mask> be relative to the instance path instead
<mask> of the application root... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | src/flask/app.py |
``str`` | <mask> must return a response. Returning ``None``, or the view ending
<mask> without returning, is not allowed. The following types are allowed
<mask> for ``view_rv``:
<mask>
<mask> ``str`` (``unicode`` in Python 2)
<mask> A response object is creat... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | src/flask/app.py |
``bytes`` | <mask> ``str`` (``unicode`` in Python 2)
<mask> A response object is created with the string encoded to UTF-8
<mask> as the body.
<mask>
<mask> ``bytes`` (``str`` in Python 2)
<mask> A response object is created with the bytes as the body.
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | src/flask/app.py |
# rightmost part. This needs to go through a helper function
# because of namespace packages. | <mask> filename = sys.modules[root_mod_name].__file__
<mask> package_path = os.path.abspath(os.path.dirname(filename))
<mask>
<mask> # In case the root module is a package we need to chop of the
<mask> # rightmost part. This needs to go through a helper function
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7673835b3da50575a14213814ea1ccefa860260f | src/flask/helpers.py |
- modules can now register for a subdomain instead of just an URL
prefix. This makes it possible to bind a whole module to a
configurable subdomain. | <mask> fully customizable with the :meth:`~flask.Flask.create_url_adapter`
<mask> method.
<mask>
<mask> .. _blinker: http://pypi.python.org/pypi/blinker
<mask>
<mask> Version 0.5.2
<mask> -------------
</s> Added support for subdomain bound modules | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7680d52f42a562eda2e3f75b34118abb08d93414 | CHANGES |
options.setdefault('subdomain', module.subdomain) | <mask> :class:`Module` class and will override the values of the module if
<mask> provided.
<mask> """
<mask> options.setdefault('url_prefix', module.url_prefix)
<mask> state = _ModuleSetupState(self, **options)
<mask> for func in module._register_events:
<mask> ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7680d52f42a562eda2e3f75b34118abb08d93414 | flask/app.py |
def __init__(self, app, url_prefix=None, subdomain=None): | <mask>
<mask>
<mask> class _ModuleSetupState(object):
<mask>
<mask> def __init__(self, app, url_prefix=None):
<mask> self.app = app
<mask> self.url_prefix = url_prefix
<mask>
<mask>
<mask> class Module(_PackageBoundObject):
</s> Added support for subdomain bound modules </s> remove ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7680d52f42a562eda2e3f75b34118abb08d93414 | flask/module.py |
self.subdomain = subdomain | <mask> def __init__(self, app, url_prefix=None, subdomain=None):
<mask> self.app = app
<mask> self.url_prefix = url_prefix
<mask>
<mask>
<mask> class Module(_PackageBoundObject):
<mask> """Container object that enables pluggable applications. A module can
<mask> be used to organiz... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7680d52f42a562eda2e3f75b34118abb08d93414 | flask/module.py |
.. versionadded:: 0.6
The `subdomain` parameter was added.
| <mask> :ref:`modules-and-resources` for more information.
<mask>
<mask> :param import_name: the name of the Python package or module
<mask> implementing this :class:`Module`.
<mask> :param name: the internal short name for the module. Unless specified
<mask> ... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7680d52f42a562eda2e3f75b34118abb08d93414 | flask/module.py |
:param subdomain: used to set the subdomain setting for URL rules that
do not have a subdomain setting set. | <mask> the rightmost part of the import name
<mask> :param url_prefix: an optional string that is used to prefix all the
<mask> URL rules of this module. This can also be specified
<mask> when registering the module with the application.
<mask> ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7680d52f42a562eda2e3f75b34118abb08d93414 | flask/module.py |
static_path=None, subdomain=None): | <mask> *from*.
<mask> """
<mask>
<mask> def __init__(self, import_name, name=None, url_prefix=None,
<mask> static_path=None):
<mask> if name is None:
<mask> assert '.' in import_name, 'name required if package name ' \
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7680d52f42a562eda2e3f75b34118abb08d93414 | flask/module.py |
self.subdomain = subdomain | <mask> name = import_name.rsplit('.', 1)[1]
<mask> _PackageBoundObject.__init__(self, import_name)
<mask> self.name = name
<mask> self.url_prefix = url_prefix
<mask> self._register_events = [_register_module(self, static_path)]
<mask>
<mask> def route(self, rule, ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7680d52f42a562eda2e3f75b34118abb08d93414 | flask/module.py |
options.setdefault('subdomain', state.subdomain) | <mask> if state.url_prefix:
<mask> the_rule = state.url_prefix + rule
<mask> the_endpoint = endpoint
<mask> if the_endpoint is None:
<mask> the_endpoint = _endpoint_from_view_func(view_func)
<mask> state.app.add_url_rule(the_rule, '%s... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7680d52f42a562eda2e3f75b34118abb08d93414 | flask/module.py |
a function and you can call that function to instantiate it, that is | <mask> ---------------------
<mask>
<mask> Sometimes you might want to use multiple instances of the same application
<mask> with different configurations. Assuming the application is created inside
<mask> a function and you can call that function to instanciate it, that is
<mask> really easy to implement. In ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/76c1a1f7227ca13f3c5952b248af93b75e9a95c9 | docs/patterns/appdispatch.rst |
the parameters from the URL rule. The class itself is instantiated with | <mask> enough to explain the basic principle. When you have a class based view
<mask> the question comes up what `self` points to. The way this works is that
<mask> whenever the request is dispatched a new instance of the class is created
<mask> and the :meth:`~flask.views.View.dispatch_request` method is called ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/76c1a1f7227ca13f3c5952b248af93b75e9a95c9 | docs/views.rst |
a function on the fly that will instantiate the :class:`View` | <mask> @classmethod
<mask> def as_view(cls, name, *class_args, **class_kwargs):
<mask> """Converts the class into an actual view function that can be
<mask> used with the routing system. What it does internally is generating
<mask> a function on the fly that will instanciate the :c... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/76c1a1f7227ca13f3c5952b248af93b75e9a95c9 | flask/views.py |
# view this thing came from, secondly it's also used for instantiating | <mask> view = decorator(view)
<mask>
<mask> # we attach the view class to the view function for two reasons:
<mask> # first of all it allows us to easily figure out what class based
<mask> # view this thing came from, secondly it's also used for instanciating
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/76c1a1f7227ca13f3c5952b248af93b75e9a95c9 | flask/views.py |
- Add type hinting. :pr:`3973`. | <mask> - ``flask shell`` sets up tab and history completion like the default
<mask> ``python`` shell if ``readline`` is installed. :issue:`3941`
<mask> - ``helpers.total_seconds()`` is deprecated. Use
<mask> ``timedelta.total_seconds()`` instead. :pr:`3962`
<mask>
<mask>
<mask> Version 1.1.2
<mask... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | CHANGES.rst |
import logging | <mask> import functools
<mask> import inspect
<mask> import os
<mask> import sys
<mask> import typing as t
<mask> import weakref
</s> Add initial type hints
This should make it easier for users to correctly use Flask. The hints
are from Quart. | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
import typing as t | <mask> import logging
<mask> import os
<mask> import sys
<mask> import weakref
<mask> from datetime import timedelta
<mask> from itertools import chain
<mask> from threading import Lock
</s> Add initial type hints
This should make it easier for users to correctly use Flask. The hints
are from Quart. | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
from types import TracebackType | <mask> from datetime import timedelta
<mask> from itertools import chain
<mask> from threading import Lock
<mask>
<mask> from werkzeug.datastructures import Headers
<mask> from werkzeug.datastructures import ImmutableDict
<mask> from werkzeug.exceptions import BadRequest
<mask> from werkzeug.exceptions import ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
from werkzeug.routing import MapAdapter | <mask> from werkzeug.routing import BuildError
<mask> from werkzeug.routing import Map
<mask> from werkzeug.routing import RequestRedirect
<mask> from werkzeug.routing import RoutingException
<mask> from werkzeug.routing import Rule
<mask> from werkzeug.wrappers import Response as BaseResponse
<mask>
<mask> fr... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
from .typing import AfterRequestCallable
from .typing import BeforeRequestCallable
from .typing import ErrorHandlerCallable
from .typing import ResponseReturnValue
from .typing import TeardownCallable
from .typing import TemplateContextProcessorCallable
from .typing import TemplateFilterCallable
from .typing import Tem... | <mask> from .signals import request_tearing_down
<mask> from .templating import DispatchingJinjaLoader
<mask> from .templating import Environment
<mask> from .wrappers import Request
<mask> from .wrappers import Response
<mask>
<mask> if t.TYPE_CHECKING:
</s> Add initial type hints
This should make it easier ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
if t.TYPE_CHECKING:
from .blueprints import Blueprint
from .testing import FlaskClient
from .testing import FlaskCliRunner | <mask> from .typing import URLValuePreprocessorCallable
<mask> from .wrappers import Request
<mask> from .wrappers import Response
<mask>
<mask>
<mask> if sys.version_info >= (3, 8):
<mask> iscoroutinefunction = inspect.iscoroutinefunction
<mask> else:
<mask>
</s> Add initial type hints
This should ma... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def iscoroutinefunction(func: t.Any) -> bool: | <mask> if sys.version_info >= (3, 8):
<mask> iscoroutinefunction = inspect.iscoroutinefunction
<mask> else:
<mask>
<mask> def iscoroutinefunction(func):
<mask> while inspect.ismethod(func):
<mask> func = func.__func__
<mask>
<mask> while isinstance(func, functools.partial)... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def _make_timedelta(value: t.Optional[timedelta]) -> t.Optional[timedelta]: | <mask>
<mask> return inspect.iscoroutinefunction(func)
<mask>
<mask>
<mask> def _make_timedelta(value):
<mask> if value is None or isinstance(value, timedelta):
<mask> return value
<mask>
<mask> return timedelta(seconds=value)
<mask>
</s> Add initial type hints
This should make ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
jinja_options: dict = {} | <mask> #: .. versionchanged:: 1.1.0
<mask> #: This is a ``dict`` instead of an ``ImmutableDict`` to allow
<mask> #: easier configuration.
<mask> #:
<mask> jinja_options = {}
<mask>
<mask> #: Default configuration parameters.
<mask> default_config = ImmutableDict(
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
test_client_class: t.Optional[t.Type["FlaskClient"]] = None | <mask>
<mask> #: the test client that is used with when `test_client` is used.
<mask> #:
<mask> #: .. versionadded:: 0.7
<mask> test_client_class = None
<mask>
<mask> #: The :class:`~click.testing.CliRunner` subclass, by default
<mask> #: :class:`~flask.testing.FlaskCliRunner` that is ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
test_cli_runner_class: t.Optional[t.Type["FlaskCliRunner"]] = None | <mask> #: :meth:`test_cli_runner`. Its ``__init__`` method should take a
<mask> #: Flask app object as the first argument.
<mask> #:
<mask> #: .. versionadded:: 1.0
<mask> test_cli_runner_class = None
<mask>
<mask> #: the session interface to use. By default an instance of
<mask> #... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
import_name: str,
static_url_path: t.Optional[str] = None,
static_folder: t.Optional[str] = "static",
static_host: t.Optional[str] = None,
host_matching: bool = False,
subdomain_matching: bool = False,
template_folder: t.Optional[str] = "templates",
instan... | <mask> session_interface = SecureCookieSessionInterface()
<mask>
<mask> def __init__(
<mask> self,
<mask> import_name,
<mask> static_url_path=None,
<mask> static_folder="static",
<mask> static_host=None,
<mask> host_matching=False,
<mask> subdom... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
self.url_build_error_handlers: t.List[
t.Callable[[Exception, str, dict], str]
] = [] | <mask> #: returns ``None`` or raises a :exc:`BuildError` the next function is
<mask> #: tried.
<mask> #:
<mask> #: .. versionadded:: 0.9
<mask> self.url_build_error_handlers = []
<mask>
<mask> #: A list of functions that will be called at the beginning of the
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
self.before_first_request_funcs: t.List[BeforeRequestCallable] = [] | <mask> #: first request to this instance. To register a function, use the
<mask> #: :meth:`before_first_request` decorator.
<mask> #:
<mask> #: .. versionadded:: 0.8
<mask> self.before_first_request_funcs = []
<mask>
<mask> #: A list of functions that are called w... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
self.teardown_appcontext_funcs: t.List[TeardownCallable] = [] | <mask> #: if the request ends this is the place to store code that disconnects
<mask> #: from databases.
<mask> #:
<mask> #: .. versionadded:: 0.9
<mask> self.teardown_appcontext_funcs = []
<mask>
<mask> #: A list of shell context processor functions that should b... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
self.shell_context_processors: t.List[t.Callable[[], t.Dict[str, t.Any]]] = [] | <mask> #: A list of shell context processor functions that should be run
<mask> #: when a shell context is created.
<mask> #:
<mask> #: .. versionadded:: 0.11
<mask> self.shell_context_processors = []
<mask>
<mask> #: Maps registered blueprint names to blueprint o... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
self.blueprints: t.Dict[str, "Blueprint"] = {} | <mask> #: Blueprints can be registered multiple times, this dict does
<mask> #: not track how often they were attached.
<mask> #:
<mask> #: .. versionadded:: 0.7
<mask> self.blueprints = {}
<mask>
<mask> #: a place where extensions can store application specific s... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
self.extensions: dict = {} | <mask> #: case of a "Flask-Foo" extension in `flask_foo`, the key would be
<mask> #: ``'foo'``.
<mask> #:
<mask> #: .. versionadded:: 0.7
<mask> self.extensions = {}
<mask>
<mask> #: The :class:`~werkzeug.routing.Map` for this instance. You can use
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
view_func=lambda **kw: self_ref().send_static_file(**kw), # type: ignore # noqa: B950 | <mask> self.add_url_rule(
<mask> f"{self.static_url_path}/<path:filename>",
<mask> endpoint="static",
<mask> host=static_host,
<mask> view_func=lambda **kw: self_ref().send_static_file(**kw),
<mask> )
<mask>
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def _is_setup_finished(self) -> bool: | <mask> # Set the name of the Click group in case someone wants to add
<mask> # the app's commands to another CLI tool.
<mask> self.cli.name = self.name
<mask>
<mask> def _is_setup_finished(self):
<mask> return self.debug and self._got_first_request
<mask>
<mask> @locked... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def name(self) -> str: # type: ignore | <mask> def _is_setup_finished(self):
<mask> return self.debug and self._got_first_request
<mask>
<mask> @locked_cached_property
<mask> def name(self):
<mask> """The name of the application. This is usually the import name
<mask> with the difference that it's guessed from the... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def propagate_exceptions(self) -> bool: | <mask> return os.path.splitext(os.path.basename(fn))[0]
<mask> return self.import_name
<mask>
<mask> @property
<mask> def propagate_exceptions(self):
<mask> """Returns the value of the ``PROPAGATE_EXCEPTIONS`` configuration
<mask> value in case it's set, otherwise a s... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def preserve_context_on_exception(self) -> bool: | <mask> return rv
<mask> return self.testing or self.debug
<mask>
<mask> @property
<mask> def preserve_context_on_exception(self):
<mask> """Returns the value of the ``PRESERVE_CONTEXT_ON_EXCEPTION``
<mask> configuration value in case it's set, otherwise a sensible def... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def logger(self) -> logging.Logger: | <mask> return rv
<mask> return self.debug
<mask>
<mask> @locked_cached_property
<mask> def logger(self):
<mask> """A standard Python :class:`~logging.Logger` for the app, with
<mask> the same name as :attr:`name`.
<mask>
<mask> In debug mode, the logger's :... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def jinja_env(self) -> Environment: | <mask> """
<mask> return create_logger(self)
<mask>
<mask> @locked_cached_property
<mask> def jinja_env(self):
<mask> """The Jinja environment used to load templates.
<mask>
<mask> The environment is created the first time this property is
<mask> accessed. Chan... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def got_first_request(self) -> bool: | <mask> """
<mask> return self.create_jinja_environment()
<mask>
<mask> @property
<mask> def got_first_request(self):
<mask> """This attribute is set to ``True`` if the application started
<mask> handling the first request.
<mask>
<mask> .. versionadded:: 0.8
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def make_config(self, instance_relative: bool = False) -> Config: | <mask> .. versionadded:: 0.8
<mask> """
<mask> return self._got_first_request
<mask>
<mask> def make_config(self, instance_relative=False):
<mask> """Used to create the config attribute by the Flask constructor.
<mask> The `instance_relative` parameter is passed in fr... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def auto_find_instance_path(self) -> str: | <mask> defaults["ENV"] = get_env()
<mask> defaults["DEBUG"] = get_debug_flag()
<mask> return self.config_class(root_path, defaults)
<mask>
<mask> def auto_find_instance_path(self):
<mask> """Tries to locate the instance path if it was not provided to the
<mask> constr... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def open_instance_resource(self, resource: str, mode: str = "rb") -> t.IO[t.AnyStr]: | <mask> if prefix is None:
<mask> return os.path.join(package_path, "instance")
<mask> return os.path.join(prefix, "var", f"{self.name}-instance")
<mask>
<mask> def open_instance_resource(self, resource, mode="rb"):
<mask> """Opens a resource from the application's instance... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def templates_auto_reload(self) -> bool: | <mask> """
<mask> return open(os.path.join(self.instance_path, resource), mode)
<mask>
<mask> @property
<mask> def templates_auto_reload(self):
<mask> """Reload templates when they are changed. Used by
<mask> :meth:`create_jinja_environment`.
<mask>
<mask> This... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def templates_auto_reload(self, value: bool) -> None: | <mask> rv = self.config["TEMPLATES_AUTO_RELOAD"]
<mask> return rv if rv is not None else self.debug
<mask>
<mask> @templates_auto_reload.setter
<mask> def templates_auto_reload(self, value):
<mask> self.config["TEMPLATES_AUTO_RELOAD"] = value
<mask>
<mask> def create_jinja_... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def create_jinja_environment(self) -> Environment: | <mask> @templates_auto_reload.setter
<mask> def templates_auto_reload(self, value):
<mask> self.config["TEMPLATES_AUTO_RELOAD"] = value
<mask>
<mask> def create_jinja_environment(self):
<mask> """Create the Jinja environment based on :attr:`jinja_options`
<mask> and the vario... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
rv.policies["json.dumps_function"] = json.dumps # type: ignore | <mask> request=request,
<mask> session=session,
<mask> g=g,
<mask> )
<mask> rv.policies["json.dumps_function"] = json.dumps
<mask> return rv
<mask>
<mask> def create_global_jinja_loader(self):
<mask> """Creates the loader for the Jinja2 e... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def create_global_jinja_loader(self) -> DispatchingJinjaLoader: | <mask> )
<mask> rv.policies["json.dumps_function"] = json.dumps
<mask> return rv
<mask>
<mask> def create_global_jinja_loader(self):
<mask> """Creates the loader for the Jinja2 environment. Can be used to
<mask> override just the loader and keeping the rest unchanged... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def select_jinja_autoescape(self, filename: str) -> bool: | <mask> .. versionadded:: 0.7
<mask> """
<mask> return DispatchingJinjaLoader(self)
<mask>
<mask> def select_jinja_autoescape(self, filename):
<mask> """Returns ``True`` if autoescaping should be active for the given
<mask> template name. If no template name is given, ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def update_template_context(self, context: dict) -> None: | <mask> if filename is None:
<mask> return True
<mask> return filename.endswith((".html", ".htm", ".xml", ".xhtml"))
<mask>
<mask> def update_template_context(self, context):
<mask> """Update the template context with some commonly used variables.
<mask> This injec... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
funcs: t.Iterable[
TemplateContextProcessorCallable
] = self.template_context_processors[None] | <mask>
<mask> :param context: the context as a dictionary that is updated in place
<mask> to add extra variables.
<mask> """
<mask> funcs = self.template_context_processors[None]
<mask> reqctx = _request_ctx_stack.top
<mask> if reqctx is not None:
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def make_shell_context(self) -> dict: | <mask> # easier add new variables in context processors without breaking
<mask> # existing views.
<mask> context.update(orig_ctx)
<mask>
<mask> def make_shell_context(self):
<mask> """Returns the shell context for an interactive shell for this
<mask> application. Thi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def debug(self) -> bool: | <mask> #: Default: ``'production'``
<mask> env = ConfigAttribute("ENV")
<mask>
<mask> @property
<mask> def debug(self):
<mask> """Whether debug mode is enabled. When using ``flask run`` to start
<mask> the development server, an interactive debugger will be shown for
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def debug(self, value: bool) -> None: | <mask> """
<mask> return self.config["DEBUG"]
<mask>
<mask> @debug.setter
<mask> def debug(self, value):
<mask> self.config["DEBUG"] = value
<mask> self.jinja_env.auto_reload = self.templates_auto_reload
<mask>
<mask> def run(self, host=None, port=None, debug=None,... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def run(
self,
host: t.Optional[str] = None,
port: t.Optional[int] = None,
debug: t.Optional[bool] = None,
load_dotenv: bool = True,
**options: t.Any,
) -> None: | <mask> def debug(self, value):
<mask> self.config["DEBUG"] = value
<mask> self.jinja_env.auto_reload = self.templates_auto_reload
<mask>
<mask> def run(self, host=None, port=None, debug=None, load_dotenv=True, **options):
<mask> """Runs the application on a local development serve... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
run_simple(t.cast(str, host), port, self, **options) | <mask>
<mask> from werkzeug.serving import run_simple
<mask>
<mask> try:
<mask> run_simple(host, port, self, **options)
<mask> finally:
<mask> # reset the first request information if the development server
<mask> # reset normally. This makes it pos... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
def test_client(self, use_cookies: bool = True, **kwargs: t.Any) -> "FlaskClient": | <mask> # reset normally. This makes it possible to restart the server
<mask> # without reloader and that stuff from an interactive shell.
<mask> self._got_first_request = False
<mask>
<mask> def test_client(self, use_cookies=True, **kwargs):
<mask> """Creates a te... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb | src/flask/app.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.