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 |
|---|---|---|---|---|
expect("/clear") | <mask> expect("/set")
<mask> expect("/get")
<mask> expect("/getitem")
<mask> expect("/setdefault")
<mask> expect("/vary-cookie-header-set")
<mask> expect("/vary-header-set", "Accept-Encoding, Accept-Language, Cookie")
<mask> expect("/no-vary-header", None)
<mask>
<mask>
<mask> de... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8705dd39c4fa563ea0fe0bf84c85da8fcc98b88d | tests/test_basic.py |
F = t.TypeVar("F", bound=t.Callable[..., t.Any]) | <mask> _sentinel = object()
<mask>
<mask>
<mask>
<mask> def setupmethod(f: F) -> F:
<mask> """Wraps a method so that it performs a check in debug mode if the
</s> Use TypeVar for setupmethod()
TypeVar is needed to preserve function signatures. The type cast for
update_wrapper is needed because wapper_fun... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8796b2a784bc45fcc6865cd80b2cba0601448727 | src/flask/scaffold.py |
def setupmethod(f: F) -> F: | <mask> # a singleton sentinel value for parameter defaults
<mask> _sentinel = object()
<mask>
<mask>
<mask> def setupmethod(f: t.Callable) -> t.Callable:
<mask> """Wraps a method so that it performs a check in debug mode if the
<mask> first request was already handled.
<mask> """
<mask>
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8796b2a784bc45fcc6865cd80b2cba0601448727 | src/flask/scaffold.py |
return t.cast(F, update_wrapper(wrapper_func, f)) | <mask> " requests."
<mask> )
<mask> return f(self, *args, **kwargs)
<mask>
<mask> return update_wrapper(wrapper_func, f)
<mask>
<mask>
<mask> class Scaffold:
<mask> """Common behavior shared between :class:`~flask.Flask` and
<mask> :class:`~flask.blueprints.B... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8796b2a784bc45fcc6865cd80b2cba0601448727 | src/flask/scaffold.py |
get_template_attribute, json | <mask>
<mask> from flask.app import Flask
<mask> from flask.helpers import url_for, jsonify, json_available, flash, send_file, \
<mask> get_flashed_messages, render_template, render_template, render_template_string, \
<mask> get_template_attribute
<mask> from flask.globals import current_app, g, request,... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8798b4b7112fb984bd244c8581ab03ef4a7ba766 | flask/__init__.py |
def _select_autoescape(filename):
"""Returns `True` if autoescaping should be active for the given
template name.
"""
if filename is None:
return False
return filename.endswith(('.html', '.htm', '.xml', '.xhtml'))
| <mask> # a lock used for logger initialization
<mask> _logger_lock = Lock()
<mask>
<mask>
<mask> class Flask(_PackageBoundObject):
<mask> """The flask object implements a WSGI application and acts as the central
<mask> object. It is passed the name of the module or package of the
<mask> applicati... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8798b4b7112fb984bd244c8581ab03ef4a7ba766 | flask/app.py |
autoescape=_select_autoescape, | <mask> )
<mask>
<mask> #: Options that are passed directly to the Jinja2 environment.
<mask> jinja_options = ImmutableDict(
<mask> autoescape=True,
<mask> extensions=['jinja2.ext.autoescape', 'jinja2.ext.with_']
<mask> )
<mask>
<mask> #: Default configuration parameters.
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8798b4b7112fb984bd244c8581ab03ef4a7ba766 | flask/app.py |
self.jinja_env = self.create_jinja_environment()
self.init_jinja_globals() | <mask>
<mask> #: The Jinja2 environment. It is created from the
<mask> #: :attr:`jinja_options` and the loader that is returned
<mask> #: by the :meth:`create_jinja_loader` function.
<mask> self.jinja_env = Environment(loader=self.create_jinja_loader(),
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8798b4b7112fb984bd244c8581ab03ef4a7ba766 | flask/app.py |
def create_jinja_environment(self):
"""Creates the Jinja2 environment based on :attr:`jinja_options`
and :meth:`create_jinja_loader`.
.. versionadded:: 0.5
"""
return Environment(loader=self.create_jinja_loader(),
**self.jinja_options)
| <mask> return logger
<mask>
<mask> def create_jinja_loader(self):
<mask> """Creates the Jinja loader. By default just a package loader for
<mask> the configured package is returned that looks up templates in the
<mask> `templates` folder. To add other loaders it's possib... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8798b4b7112fb984bd244c8581ab03ef4a7ba766 | flask/app.py |
def init_jinja_globals(self):
"""Callde directly after the environment was created to inject
some defaults (like `url_for`, `get_flashed_messages` and the
`tojson` filter.
.. versionadded:: 0.5
"""
self.jinja_env.globals.update(
url_for=url_for,
... | <mask> return PackageLoader(self.import_name)
<mask>
<mask> def update_template_context(self, context):
<mask> """Update the template context with some commonly used variables.
<mask> This injects request, session and g into the template context.
<mask>
</s> Merged in changes from m... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8798b4b7112fb984bd244c8581ab03ef4a7ba766 | flask/app.py |
<mask> from contextlib import contextmanager
<mask> from datetime import datetime
<mask> from werkzeug import parse_date, parse_options_header
<mask> from cStringIO import StringIO
<mask> from flask.helpers import json
<mask>
<mask> example_path = os.path.join(os.path.dirname(__file__), '..', 'examples')
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8798b4b7112fb984bd244c8581ab03ef4a7ba766 | tests/flask_tests.py | |
assert flask.json.loads(rv.data) == d | <mask> c = app.test_client()
<mask> for url in '/kw', '/dict':
<mask> rv = c.get(url)
<mask> assert rv.mimetype == 'application/json'
<mask> assert json.loads(rv.data) == d
<mask>
<mask> def test_json_attr(self):
<mask> app = flask.Flask(__name__)... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8798b4b7112fb984bd244c8581ab03ef4a7ba766 | tests/flask_tests.py |
rv = c.post('/add', data=flask.json.dumps({'a': 1, 'b': 2}), | <mask> @app.route('/add', methods=['POST'])
<mask> def add():
<mask> return unicode(flask.request.json['a'] + flask.request.json['b'])
<mask> c = app.test_client()
<mask> rv = c.post('/add', data=json.dumps({'a': 1, 'b': 2}),
<mask> content_t... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8798b4b7112fb984bd244c8581ab03ef4a7ba766 | tests/flask_tests.py |
$ FLASK_ENV=development flask run | <mask> when running the development server.
<mask>
<mask> ::
<mask>
<mask> $ FLASK_DEBUG=1 flask run
<mask> * Serving Flask app "hello"
<mask> * Forcing debug mode on
<mask> * Env production
<mask> * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
<mask> * Restarting wi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/cli.rst |
The :data:`ENV` and :data:`DEBUG` config values are special because they
may behave inconsistently if changed after the app has begun setting up.
In order to set the environment and debug mode reliably, Flask uses
environment variables. | <mask>
<mask> Environment and Debug Features
<mask> ------------------------------
<mask>
<mask> Some values are special in that they can show unexpected behavior when
<mask> changed late. In particular that applies to the Flask environment and
<mask> debug mode.
<mask>
<mask> If you use the :command:`flas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/config.rst |
The environment is used to indicate to Flask, extensions, and other
programs, like Sentry, what context Flask is running in. It is
controlled with the :envvar:`FLASK_ENV` environment variable and
defaults to ``production``. | <mask> Some values are special in that they can show unexpected behavior when
<mask> changed late. In particular that applies to the Flask environment and
<mask> debug mode.
<mask>
<mask> If you use the :command:`flask` script to start a local development server
<mask> for instance you should tell Flask that yo... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/config.rst |
Setting :envvar:`FLASK_ENV` to ``development`` will enable debug mode.
``flask run`` will use the interactive debugger and reloader by default
in debug mode. To control this separately from the environment, use the
:envvar:`FLASK_DEBUG` flag.
.. versionchanged:: 1.0
Added :envvar:`FLASK_ENV` to control the environ... | <mask> environment to production mode instead of development. This is done
<mask> because development mode can turn on potentially unsafe features such as
<mask> the debugger by default.
<mask>
<mask> To control the environment and such fundamental features Flask provides
<mask> the two environment variables :e... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/config.rst |
To switch Flask to the development environment and enable debug mode,
set :envvar:`FLASK_ENV`:: | <mask> the two environment variables :envvar:`FLASK_ENV` and :envvar:`FLASK_DEBUG`.
<mask> In versions of Flask older than 1.0 the :envvar:`FLASK_ENV` environment
<mask> variable did not exist.
<mask>
<mask> The most common way to switch Flask to development mode is to tell it to
<mask> work on the ``development... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/config.rst |
$ export FLASK_ENV=development
$ flask run | <mask>
<mask> The most common way to switch Flask to development mode is to tell it to
<mask> work on the ``development`` environment::
<mask>
<mask> $ export FLASK_ENV=development
<mask> $ flask run
<mask>
<mask> (On Windows you need to use ``set`` instead of ``export``).
<mask>
<mask> While you can atte... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/config.rst |
(On Windows, use ``set`` instead of ``export``.)
Using the environment variables as described above is recommended. While
it is possible to set :data:`ENV` and :data:`DEBUG` in your config or
code, this is strongly discouraged. They can't be read early by the
``flask`` command, and some systems or extensions may have ... | <mask>
<mask> $ export FLASK_ENV=development
<mask> $ flask run
<mask>
<mask> (On Windows you need to use ``set`` instead of ``export``).
<mask>
<mask> While you can attempt to flip the environment and debug flag separately in
<mask> the Flask config from the config file this is strongly discouraged as
<mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/config.rst |
<mask> $ flask run
<mask>
<mask> (On Windows you need to use ``set`` instead of ``export``).
<mask>
<mask> While you can attempt to flip the environment and debug flag separately in
<mask> the Flask config from the config file this is strongly discouraged as
<mask> those flags are often loaded early and changi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/config.rst | |
.. py:data:: ENV
What environment the app is running in. Flask and extensions may
enable behaviors based on the environment, such as enabling debug
mode. The :attr:`~flask.Flask.env` attribute maps to this config
key. This is set by the :envvar:`FLASK_ENV` environment variable and
may not behave as... | <mask> ----------------------------
<mask>
<mask> The following configuration values are used internally by Flask:
<mask>
<mask> .. py:data:: DEBUG
<mask>
<mask> Whether debug mode is enabled. When using ``flask run`` to start the
<mask> development server, an interactive debugger will be shown for
... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/config.rst |
Whether debug mode is enabled. When using ``flask run`` to start the
development server, an interactive debugger will be shown for
unhandled exceptions, and the server will be reloaded when code
changes. The :attr:`~flask.Flask.debug` attribute maps to this
config key. This is enabled when :data:`EN... | <mask> The following configuration values are used internally by Flask:
<mask>
<mask> .. py:data:: DEBUG
<mask>
<mask> Enable debug mode. When using the development server with ``flask run`` or
<mask> ``app.run``, an interactive debugger will be shown for unhanlded
<mask> exceptions, and the server... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/config.rst |
**Do not enable debug mode when deploying in production.** | <mask> Enable debug mode. When using the development server with ``flask run`` or
<mask> ``app.run``, an interactive debugger will be shown for unhanlded
<mask> exceptions, and the server will be reloaded when code changes.
<mask>
<mask> **Do not enable debug mode in production.**
<mask>
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/config.rst |
Default: ``True`` if :data:`ENV` is ``'production'``, or ``False``
otherwise. | <mask> exceptions, and the server will be reloaded when code changes.
<mask>
<mask> **Do not enable debug mode in production.**
<mask>
<mask> Default: ``False``
<mask>
<mask> .. py:data:: TESTING
<mask>
<mask> Enable testing mode. Exceptions are propagated rather than handled by the
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/config.rst |
Added :data:`ENV` to reflect the :envvar:`FLASK_ENV` environment
variable.
| <mask> ``LOGGER_NAME`` and ``LOGGER_HANDLER_POLICY`` were removed. See
<mask> :ref:`logging` for information about configuration.
<mask>
<mask> Configuring from Files
<mask> ----------------------
<mask>
<mask> Configuration becomes more useful if you can store it in a separate file,
</s> clean up FLA... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/config.rst |
To enable all development features (including debug mode) you can export
the ``FLASK_ENV`` environment variable and set it to ``development`` | <mask> That is not very nice and Flask can do better. If you enable debug
<mask> support the server will reload itself on code changes, and it will also
<mask> provide you with a helpful debugger if things go wrong.
<mask>
<mask> To enable all development features (and to disable the debug mode) you can
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/quickstart.rst |
(On Windows you need to use ``set`` instead of ``export``.) | <mask>
<mask> $ export FLASK_ENV=development
<mask> $ flask run
<mask>
<mask> (On Windows you need to use ``set`` instead of ``export`` and on Flask
<mask> versions older than 1.0 you need to export ``FLASK_DEBUG=1`` instead).
<mask>
<mask> This does the following things:
<mask>
<mask> 1. it acti... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/quickstart.rst |
You can also control debug mode separately from the environment by
exporting ``FLASK_DEBUG=1``.
| <mask> 2. it activates the automatic reloader
<mask> 3. it enables the debug mode on the Flask application.
<mask>
<mask> There are more parameters that are explained in the :ref:`server` docs.
<mask>
<mask> .. admonition:: Attention
<mask>
<mask> Even though the interactive debugger does not work in fo... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/quickstart.rst |
This enables the development environment, including the interactive
debugger and reloader, and then starts the server on | <mask> $ export FLASK_APP=my_application
<mask> $ export FLASK_ENV=development
<mask> $ flask run
<mask>
<mask> This will enable the debugger, the reloader and then start the server on
<mask> *http://localhost:5000/*.
<mask>
<mask> The individual features of the server can be controlled by passing... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/server.rst |
arguments to the ``run`` option. For instance the reloader can be | <mask> This will enable the debugger, the reloader and then start the server on
<mask> *http://localhost:5000/*.
<mask>
<mask> The individual features of the server can be controlled by passing more
<mask> arguments to the ``run`` option. For instance the reloader can be
<mask> disabled::
<mask>
<mask> $... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/server.rst |
Prior to Flask 1.0 the :envvar:`FLASK_ENV` environment variable was
not supported and you needed to enable debug mode by exporting
``FLASK_DEBUG=1``. This can still be used to control debug mode, but
you should prefer setting the development environment as shown
above. | <mask> $ flask run --no-reload
<mask>
<mask> .. note::
<mask>
<mask> On older Flask version (before 1.0) the :envvar:`FLASK_ENV`
<mask> environment variable is not supported and you need to enable the
<mask> debug mode separately by setting the :envvar:`FLASK_DEBUG` environment
<mask> vari... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/server.rst |
Exporting ``FLASK_ENV=development`` turns on all development features
such as enabling the interactive debugger. | <mask> export FLASK_ENV=development
<mask> flask run
<mask>
<mask> (In case you are on Windows you need to use ``set`` instead of ``export``).
<mask> The :envvar:`FLASK_ENV` flag if set to ``development`` turns on all
<mask> development features such as enabling the interactive debugger.
<mask>
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | docs/tutorial/packaging.rst |
#: What environment the app is running in. Flask and extensions may
#: enable behaviors based on the environment, such as enabling debug
#: mode. This maps to the :data:`ENV` config key. This is set by the
#: :envvar:`FLASK_ENV` environment variable and may not behave as
#: expected if set in code.
... | <mask> for processor in self.shell_context_processors:
<mask> rv.update(processor())
<mask> return rv
<mask>
<mask> #: The environment value. This is typically set from outside the
<mask> #: process by setting the `FLASK_ENV` environment variable and can be
<mask> #: use... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | flask/app.py |
self.config['DEBUG'] = value
self.jinja_env.auto_reload = self.templates_auto_reload | <mask>
<mask> def _get_debug(self):
<mask> return self.config['DEBUG']
<mask> def _set_debug(self, value):
<mask> self._set_debug_value(value)
<mask>
<mask> #: The debug flag. If this is ``True`` it enables debugging of the
<mask> #: application. In debug mode the debugger wi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | flask/app.py |
#: Whether debug mode is enabled. When using ``flask run`` to start
#: the development server, an interactive debugger will be shown for
#: unhandled exceptions, and the server will be reloaded when code
#: changes. This maps to the :data:`DEBUG` config key. This is
#: enabled when :attr:`env` is ``... | <mask> return self.config['DEBUG']
<mask> def _set_debug(self, value):
<mask> self._set_debug_value(value)
<mask>
<mask> #: The debug flag. If this is ``True`` it enables debugging of the
<mask> #: application. In debug mode the debugger will kick in when an
<mask> #: unhandled... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | flask/app.py |
#: **Do not enable debug mode when deploying in production.**
#:
#: Default: ``True`` if :attr:`env` is ``'development'``, or
#: ``False`` otherwise. | <mask> #: unhandled exception occurs and the integrated server will
<mask> #: automatically reload the application if changes in the code are
<mask> #: detected.
<mask> #:
<mask> #: This value should only be configured by the :envvar:`FLASK_DEBUG`
<mask> #: environment variable. Changing ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | flask/app.py |
<mask> #: otherwise.
<mask> debug = property(_get_debug, _set_debug)
<mask> del _get_debug, _set_debug
<mask>
<mask> def _set_debug_value(self, value):
<mask> self.config['DEBUG'] = value
<mask> self.jinja_env.auto_reload = self.templates_auto_reload
<mask>
<mask> def run(... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | flask/app.py | |
"""Get the environment the app is running in, indicated by the
:envvar:`FLASK_ENV` environment variable. The default is
``'production'``.
"""
return os.environ.get('FLASK_ENV') or 'production' | <mask> if sep not in (None, '/'))
<mask>
<mask>
<mask> def get_env():
<mask> val = os.environ.get('FLASK_ENV')
<mask> if not val:
<mask> val = 'production'
<mask> return val
<mask>
<mask>
<mask> def get_debug_flag():
<mask> val = os.environ.get('FLASK_DEBUG')
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | flask/helpers.py |
"""Get whether debug mode should be enabled for the app, indicated
by the :envvar:`FLASK_DEBUG` environment variable. The default is
``True`` if :func:`.get_env` returns ``'development'``, or ``False``
otherwise.
""" | <mask>
<mask> def get_debug_flag():
<mask> val = os.environ.get('FLASK_DEBUG')
<mask>
<mask> if not val:
<mask> return get_env() == 'development'
</s> clean up FLASK_ENV docs [ci skip] </s> remove env = get_env()
if env == 'development':
return True
return Fa... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | flask/helpers.py |
return get_env() == 'development'
| <mask>
<mask> def get_debug_flag():
<mask> val = os.environ.get('FLASK_DEBUG')
<mask> if not val:
<mask> env = get_env()
<mask> if env == 'development':
<mask> return True
<mask> return False
<mask> return val.lower() not in ('0', 'false', 'no')
<mask>
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/87c2e121e0bf32f5234eabbf4773a82f9d5523d2 | flask/helpers.py |
- Relax typing for ``errorhandler`` to allow the user to use more
precise types and decorate the same function multiple times.
:issue:`4095, 4295, 4297` | <mask> context from the ``flask run`` command remains available in the
<mask> loader thread. :issue:`4460`
<mask> - Deleting the session cookie uses the ``httponly`` flag.
<mask> :issue:`4485`
<mask>
<mask>
<mask> Version 2.0.3
<mask> -------------
</s> relax errorhandler function arg type </s>... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/88863288225d5ee13a79c463f2a39391b6a52c61 | CHANGES.rst |
def _find_error_handler(self, e: Exception) -> t.Optional["ErrorHandlerCallable"]: | <mask> """
<mask> self.shell_context_processors.append(f)
<mask> return f
<mask>
<mask> def _find_error_handler(
<mask> self, e: Exception
<mask> ) -> t.Optional["ErrorHandlerCallable[Exception]"]:
<mask> """Return a registered error handler for an exception in t... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/88863288225d5ee13a79c463f2a39391b6a52c61 | src/flask/app.py |
def decorator(f: "ErrorHandlerCallable") -> "ErrorHandlerCallable": | <mask> """Like :meth:`Flask.errorhandler` but for a blueprint. This
<mask> handler is used for all requests, even if outside of the blueprint.
<mask> """
<mask>
<mask> def decorator(
<mask> f: "ErrorHandlerCallable[Exception]",
<mask> ) -> "ErrorHandlerCallab... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/88863288225d5ee13a79c463f2a39391b6a52c61 | src/flask/blueprints.py |
def decorator(f: "ErrorHandlerCallable") -> "ErrorHandlerCallable": | <mask> :param code_or_exception: the code as integer for the handler, or
<mask> an arbitrary exception
<mask> """
<mask>
<mask> def decorator(
<mask> f: "ErrorHandlerCallable[GenericException]",
<mask> ) -> "ErrorHandlerCallable[Gener... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/88863288225d5ee13a79c463f2a39391b6a52c61 | src/flask/scaffold.py |
code_or_exception: t.Union[t.Type[Exception], int],
f: "ErrorHandlerCallable", | <mask>
<mask> @setupmethod
<mask> def register_error_handler(
<mask> self,
<mask> code_or_exception: t.Union[t.Type[GenericException], int],
<mask> f: "ErrorHandlerCallable[GenericException]",
<mask> ) -> None:
<mask> """Alternative error attach function to the :meth... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/88863288225d5ee13a79c463f2a39391b6a52c61 | src/flask/scaffold.py |
self.error_handler_spec[None][code][exc_class] = f | <mask> " code. Use a subclass of HTTPException with that code"
<mask> " instead."
<mask> ) from None
<mask>
<mask> self.error_handler_spec[None][code][exc_class] = t.cast(
<mask> "ErrorHandlerCallable[Exception]", f
<mask> )
<mask>
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/88863288225d5ee13a79c463f2a39391b6a52c61 | src/flask/scaffold.py |
<mask> t.Tuple[ResponseValue, StatusCode, HeadersValue],
<mask> "WSGIApplication",
<mask> ]
<mask>
<mask> GenericException = t.TypeVar("GenericException", bound=Exception, contravariant=True)
<mask>
<mask> AppOrBlueprintKey = t.Optional[str] # The App key is None, whereas blueprints are named
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/88863288225d5ee13a79c463f2a39391b6a52c61 | src/flask/typing.py | |
# This should take Exception, but that either breaks typing the argument
# with a specific exception, or decorating multiple times with different
# exceptions (and using a union type on the argument).
# https://github.com/pallets/flask/issues/4095
# https://github.com/pallets/flask/issues/4295
# https://github.com/pall... | <mask> TemplateGlobalCallable = t.Callable[..., t.Any]
<mask> TemplateTestCallable = t.Callable[..., bool]
<mask> URLDefaultCallable = t.Callable[[str, dict], None]
<mask> URLValuePreprocessorCallable = t.Callable[[t.Optional[str], t.Optional[dict]], None]
<mask> ErrorHandlerCallable = t.Callable[[GenericException... | [
"keep",
"keep",
"keep",
"keep",
"replace"
] | https://github.com/pallets/flask/commit/88863288225d5ee13a79c463f2a39391b6a52c61 | src/flask/typing.py |
.. admonition:: A note on python3 and virtualenv
If you are planning on using python3 with the virtualenv, you don't need to
install ``virtualenv``. Python3 has built-in support for virtual environments.
| <mask> project environments isolated. Let's see how virtualenv works.
<mask>
<mask> If you are on Mac OS X or Linux, chances are that the following
<mask> command will work for you::
<mask>
<mask> $ sudo pip install virtualenv
<mask>
<mask> It will probably install virtualenv on your system. Maybe it's... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/889c0ed1964f48557e532f95f9003c5ee6e2b727 | docs/installation.rst |
Creating a virtual environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| <mask> install it first. Check the :ref:`windows-easy-install` section for more
<mask> information about how to do that. Once you have it installed, run the same
<mask> commands as above, but without the ``sudo`` prefix.
<mask>
<mask> Once you have virtualenv installed, just fire up a shell and create
<mask> y... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/889c0ed1964f48557e532f95f9003c5ee6e2b727 | docs/installation.rst |
your own environment. I usually create a project folder and a :file:`virtenv` | <mask> information about how to do that. Once you have it installed, run the same
<mask> commands as above, but without the ``sudo`` prefix.
<mask>
<mask> Once you have virtualenv installed, just fire up a shell and create
<mask> your own environment. I usually create a project folder and a :file:`venv`
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/889c0ed1964f48557e532f95f9003c5ee6e2b727 | docs/installation.rst |
There is a little change in how you create a virtualenv depending on which python-version you are currently using.
**Python2**
::
$ virtualenv virtenv
New python executable in virtenv/bin/python | <mask> folder within::
<mask>
<mask> $ mkdir myproject
<mask> $ cd myproject
<mask> $ virtualenv venv
<mask> New python executable in venv/bin/python
<mask> Installing setuptools, pip............done.
<mask>
<mask> Now, whenever you want to work on a project, you only have to activate the... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/889c0ed1964f48557e532f95f9003c5ee6e2b727 | docs/installation.rst |
**Python 3.6 and above**
::
$ python3 -m venv virtenv
Activating a virtual environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| <mask> $ virtualenv virtenv
<mask> New python executable in virtenv/bin/python
<mask> Installing setuptools, pip............done.
<mask>
<mask> Now, whenever you want to work on a project, you only have to activate the
<mask> corresponding environment. On OS X and Linux, do the following::
<mask>
... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/889c0ed1964f48557e532f95f9003c5ee6e2b727 | docs/installation.rst |
$ . virtenv/bin/activate | <mask>
<mask> Now, whenever you want to work on a project, you only have to activate the
<mask> corresponding environment. On OS X and Linux, do the following::
<mask>
<mask> $ . venv/bin/activate
<mask>
<mask> If you are a Windows user, the following command is for you::
<mask>
<mask> $ venv\Scri... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/889c0ed1964f48557e532f95f9003c5ee6e2b727 | docs/installation.rst |
$ virtenv\Scripts\activate | <mask> $ . venv/bin/activate
<mask>
<mask> If you are a Windows user, the following command is for you::
<mask>
<mask> $ venv\Scripts\activate
<mask>
<mask> Either way, you should now be using your virtualenv (notice how the prompt of
<mask> your shell has changed to show the active environment).
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/889c0ed1964f48557e532f95f9003c5ee6e2b727 | docs/installation.rst |
$ virtualenv virtenv
New python executable in virtenv/bin/python | <mask>
<mask> $ git clone https://github.com/pallets/flask.git
<mask> Initialized empty Git repository in ~/dev/flask/.git/
<mask> $ cd flask
<mask> $ virtualenv venv
<mask> New python executable in venv/bin/python
<mask> Installing setuptools, pip............done.
<mask> $ . venv/b... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/889c0ed1964f48557e532f95f9003c5ee6e2b727 | docs/installation.rst |
$ . virtenv/bin/activate | <mask> $ cd flask
<mask> $ virtualenv venv
<mask> New python executable in venv/bin/python
<mask> Installing setuptools, pip............done.
<mask> $ . venv/bin/activate
<mask> $ python setup.py develop
<mask> ...
<mask> Finished processing dependencies for Flask
<mask>
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/889c0ed1964f48557e532f95f9003c5ee6e2b727 | docs/installation.rst |
- ``instance_path`` for namespace packages uses the path closest to
the imported submodule. :issue:`4600` | <mask> - Inline some optional imports that are only used for certain CLI
<mask> commands. :pr:`4606`
<mask> - Relax type annotation for ``after_request`` functions. :issue:`4600`
<mask>
<mask>
<mask> Version 2.1.2
<mask> -------------
<mask>
</s> instance_path for namespace packages uses path closes... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/88bcf78439b66b5fcba9f4d3a1c56307f98dbf1d | CHANGES.rst |
def _find_package_path(import_name): | <mask> f" import hooks."
<mask> )
<mask>
<mask>
<mask> def _find_package_path(root_mod_name):
<mask> """Find the path that contains the package or module."""
<mask> try:
<mask> spec = importlib.util.find_spec(root_mod_name)
<mask>
<mask> if spec is None:
</s> instance_p... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/88bcf78439b66b5fcba9f4d3a1c56307f98dbf1d | src/flask/scaffold.py |
root_mod_name, _, _ = import_name.partition(".")
| <mask>
<mask> def _find_package_path(import_name):
<mask> """Find the path that contains the package or module."""
<mask> try:
<mask> root_spec = importlib.util.find_spec(root_mod_name)
<mask>
<mask> if root_spec is None:
<mask> raise ValueError("not found")
<mask> # I... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/88bcf78439b66b5fcba9f4d3a1c56307f98dbf1d | src/flask/scaffold.py |
root_spec = importlib.util.find_spec(root_mod_name) | <mask>
<mask> def _find_package_path(root_mod_name):
<mask> """Find the path that contains the package or module."""
<mask> try:
<mask> spec = importlib.util.find_spec(root_mod_name)
<mask>
<mask> if spec is None:
<mask> raise ValueError("not found")
<mask> # ImportErr... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/88bcf78439b66b5fcba9f4d3a1c56307f98dbf1d | src/flask/scaffold.py |
if root_spec is None: | <mask> """Find the path that contains the package or module."""
<mask> try:
<mask> spec = importlib.util.find_spec(root_mod_name)
<mask>
<mask> if spec is None:
<mask> raise ValueError("not found")
<mask> # ImportError: the machinery told us it does not exist
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/88bcf78439b66b5fcba9f4d3a1c56307f98dbf1d | src/flask/scaffold.py |
# - *we* raised `ValueError` due to `root_spec` being `None` | <mask> # ImportError: the machinery told us it does not exist
<mask> # ValueError:
<mask> # - the module name was invalid
<mask> # - the module name is __main__
<mask> # - *we* raised `ValueError` due to `spec` being `None`
<mask> except (ImportError, ValueError):
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/88bcf78439b66b5fcba9f4d3a1c56307f98dbf1d | src/flask/scaffold.py |
if root_spec.origin in {"namespace", None}:
package_spec = importlib.util.find_spec(import_name)
if package_spec is not None and package_spec.submodule_search_locations:
# Pick the path in the namespace that contains the submodule.
package_path = os.path.c... | <mask> except (ImportError, ValueError):
<mask> pass # handled below
<mask> else:
<mask> # namespace package
<mask> if spec.origin in {"namespace", None}:
<mask> return os.path.dirname(next(iter(spec.submodule_search_locations)))
<mask> # a package (with __ini... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/88bcf78439b66b5fcba9f4d3a1c56307f98dbf1d | src/flask/scaffold.py |
elif root_spec.submodule_search_locations:
return os.path.dirname(os.path.dirname(root_spec.origin)) | <mask> # namespace package
<mask> if spec.origin in {"namespace", None}:
<mask> return os.path.dirname(next(iter(spec.submodule_search_locations)))
<mask> # a package (with __init__.py)
<mask> elif spec.submodule_search_locations:
<mask> return os.path.dirna... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/88bcf78439b66b5fcba9f4d3a1c56307f98dbf1d | src/flask/scaffold.py |
return os.path.dirname(root_spec.origin) | <mask> elif spec.submodule_search_locations:
<mask> return os.path.dirname(os.path.dirname(spec.origin))
<mask> # just a normal module
<mask> else:
<mask> return os.path.dirname(spec.origin)
<mask>
<mask> # we were unable to find the `package_path` using PEP 4... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/88bcf78439b66b5fcba9f4d3a1c56307f98dbf1d | src/flask/scaffold.py |
package_path = _find_package_path(import_name) | <mask> The path is the entry in :attr:`sys.path` that contains the package
<mask> for import. If the package is not installed, it's assumed that the
<mask> package was imported from the current working directory.
<mask> """
<mask> root_mod_name, _, _ = import_name.partition(".")
<mask> pac... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/88bcf78439b66b5fcba9f4d3a1c56307f98dbf1d | src/flask/scaffold.py |
- ``jsonify`` handles ``decimal.Decimal`` by encoding to ``str``.
:issue:`4157` | <mask> - Fix the type of ``static_folder`` to accept ``pathlib.Path``.
<mask> :issue:`4150`
<mask>
<mask>
<mask> Version 2.0.1
<mask> -------------
</s> jsonify encodes decimal to str </s> remove if isinstance(o, uuid.UUID):
</s> add if isinstance(o, (decimal.Decimal, uuid.UUID)): | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/892ae955093cc3b7925230ff7bc346a6afb14f5d | CHANGES.rst |
if isinstance(o, (decimal.Decimal, uuid.UUID)): | <mask> serialized, they are handled before this method.
<mask> """
<mask> if isinstance(o, date):
<mask> return http_date(o)
<mask> if isinstance(o, uuid.UUID):
<mask> return str(o)
<mask> if dataclasses and dataclasses.is_dataclass(o):
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/892ae955093cc3b7925230ff7bc346a6afb14f5d | src/flask/json/__init__.py |
.. versionchanged:: 2.0.2
:class:`decimal.Decimal` is supported by converting to a string.
| <mask> :param app: Use this app's config instead of the active app context
<mask> or defaults.
<mask> :param kwargs: Extra arguments passed to :func:`json.dumps`.
<mask>
<mask> .. versionchanged:: 2.0
<mask> ``encoding`` is deprecated and will be removed in Flask 2.1.
<mask>
<mask>... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/892ae955093cc3b7925230ff7bc346a6afb14f5d | src/flask/json/__init__.py |
.. versionchanged:: 2.0.2
:class:`decimal.Decimal` is supported by converting to a string.
| <mask> debug mode or if :data:`JSONIFY_PRETTYPRINT_REGULAR` is ``True``,
<mask> the output will be formatted to be easier to read.
<mask>
<mask> .. versionchanged:: 0.11
<mask> Added support for serializing top-level arrays. This introduces
<mask> a security risk in ancient browsers. ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/892ae955093cc3b7925230ff7bc346a6afb14f5d | src/flask/json/__init__.py |
import decimal | <mask> import datetime
<mask> import io
<mask> import uuid
<mask>
<mask> import pytest
<mask> from werkzeug.http import http_date
</s> jsonify encodes decimal to str </s> remove if isinstance(o, uuid.UUID):
</s> add if isinstance(o, (decimal.Decimal, uuid.UUID)): | [
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/892ae955093cc3b7925230ff7bc346a6afb14f5d | tests/test_json.py |
def test_json_decimal():
rv = flask.json.dumps(decimal.Decimal("0.003"))
assert rv == '"0.003"'
| <mask> assert rv_uuid == test_uuid
<mask>
<mask>
<mask> def test_json_attr(app, client):
<mask> @app.route("/add", methods=["POST"])
<mask> def add():
<mask> json = flask.request.get_json()
<mask> return str(json["a"] + json["b"])
</s> jsonify encodes decimal to str </s> remove ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/892ae955093cc3b7925230ff7bc346a6afb14f5d | tests/test_json.py |
from werkzeug.exceptions import NotFound | <mask> except ImportError:
<mask> json_available = False
<mask>
<mask> from werkzeug import Headers, wrap_file, is_resource_modified, cached_property
<mask>
<mask> from jinja2 import FileSystemLoader
<mask>
<mask> from .globals import session, _request_ctx_stack, current_app, request
</s> fixed ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8945a97a42d6475b1ee9fcb2689dc65dfce9828f | flask/helpers.py |
if filename.startswith(('/', '../')): | <mask>
<mask> .. versionadded:: 0.5
<mask> """
<mask> filename = posixpath.normpath(filename)
<mask> if filename.startswith('../'):
<mask> raise NotFound()
<mask> filename = os.path.join(self.root_path, 'static', filename)
<mask> if not os.path.isfile... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8945a97a42d6475b1ee9fcb2689dc65dfce9828f | flask/helpers.py |
from werkzeug.exceptions import NotFound | <mask> from logging import StreamHandler
<mask> from contextlib import contextmanager
<mask> from datetime import datetime
<mask> from werkzeug import parse_date, parse_options_header
<mask> from cStringIO import StringIO
<mask>
<mask> example_path = os.path.join(os.path.dirname(__file__), '..', 'examples')
<m... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8945a97a42d6475b1ee9fcb2689dc65dfce9828f | tests/flask_tests.py |
- Mark top-level names as exported so type checking understands
imports in user projects. :issue:`4024` | <mask> - Re-add the ``filename`` parameter in ``send_from_directory``. The
<mask> ``filename`` parameter has been renamed to ``path``, the old name
<mask> is deprecated. :pr:`4019`
<mask>
<mask>
<mask> Version 2.0.0
<mask> -------------
</s> mark top-level names as exported </s> remove from . import... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/89475e5d1e3e25ce56c9d9411496528f4a1ba82b | CHANGES.rst |
from werkzeug.exceptions import abort as abort
from werkzeug.utils import redirect as redirect | <mask> from markupsafe import escape
<mask> from markupsafe import Markup
<mask> from werkzeug.exceptions import abort
<mask> from werkzeug.utils import redirect
<mask>
<mask> from . import json
<mask> from .app import Flask
<mask> from .app import Request
<mask> from .app import Response
</s> mark top-level... | [
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/89475e5d1e3e25ce56c9d9411496528f4a1ba82b | src/flask/__init__.py |
from . import json as json
from .app import Flask as Flask
from .app import Request as Request
from .app import Response as Response
from .blueprints import Blueprint as Blueprint
from .config import Config as Config
from .ctx import after_this_request as after_this_request
from .ctx import copy_current_request_context... | <mask> from markupsafe import Markup
<mask> from werkzeug.exceptions import abort
<mask> from werkzeug.utils import redirect
<mask>
<mask> from . import json
<mask> from .app import Flask
<mask> from .app import Request
<mask> from .app import Response
<mask> from .blueprints import Blueprint
<mask> from .co... | [
"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/89475e5d1e3e25ce56c9d9411496528f4a1ba82b | src/flask/__init__.py |
<mask>
<mask> This will link to ``admin.index`` for instance in case the current request
<mask> was dispatched to any other admin blueprint endpoint.
<mask>
<mask> .. _my-blueprint-error-label:
<mask>
<mask> Blueprint Error Handlers
<mask> ------------------------
<mask>
<mask> Blueprints support the ``er... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/89d1487b2ed0eb4fc4fb49a50eb54b942bec4193 | docs/blueprints.rst | |
<mask> - `Getting started with Sentry <https://docs.sentry.io/quickstart/?platform=python>`__
<mask> - `Flask-specific documentation <https://docs.sentry.io/platforms/python/flask/>`__
<mask>
<mask>
<mask> .. _error-handlers:
<mask>
<mask> Error Handlers
<mask> --------------
<mask>
<mask> When an err... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/89d1487b2ed0eb4fc4fb49a50eb54b942bec4193 | docs/errorhandling.rst | |
See :doc:`/logging` for information about how to log exceptions, such as
by emailing them to admins. | <mask>
<mask> Logging
<mask> -------
<mask>
<mask> See :doc:`/logging` for information on how to log exceptions, such as by
<mask> emailing them to admins.
<mask>
<mask> Debugging Application Errors
<mask> ============================
<mask>
<mask> For production applications, configure your application ... | [
"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/89d1487b2ed0eb4fc4fb49a50eb54b942bec4193 | docs/errorhandling.rst |
<mask> The built-in development server provides a :ref:`debug-mode` that shows
<mask> an interactive traceback in the browser when an unhandled error occurs
<mask> during a request.
<mask>
<mask> External debuggers, such as those provided by IDEs, can offer a much
<mask> more powerful and visual debugging experi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
... | https://github.com/pallets/flask/commit/89d1487b2ed0eb4fc4fb49a50eb54b942bec4193 | docs/errorhandling.rst | |
Debugging
--------- | <mask> When running from Python:
<mask>
<mask> .. code-block:: python
<mask>
<mask> app.run(debug=True, use_debugger=False, use_reloader=False)
<mask>
<mask> Disabling these isn't required, an external debugger will continue to
<mask> work with the following caveats. If the built-in debugger is not
<mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/89d1487b2ed0eb4fc4fb49a50eb54b942bec4193 | docs/errorhandling.rst |
See :doc:`/debugging` for information about how to debug errors in
development and production. | <mask> .. code-block:: python
<mask>
<mask> app.run(debug=True, use_debugger=False, use_reloader=False)
<mask>
<mask> Disabling these isn't required, an external debugger will continue to
<mask> work with the following caveats. If the built-in debugger is not
<mask> disabled, it will catch unhandled except... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace"
] | https://github.com/pallets/flask/commit/89d1487b2ed0eb4fc4fb49a50eb54b942bec4193 | docs/errorhandling.rst |
debugging | <mask> tutorial/index
<mask> templating
<mask> testing
<mask> errorhandling
<mask> logging
<mask> config
<mask> signals
<mask> views
<mask> appcontext
<mask> reqcontext
</s> rewrite debugging docs, move to separate page </s> remove See :doc:`/logging` for information on how to l... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/89d1487b2ed0eb4fc4fb49a50eb54b942bec4193 | docs/index.rst |
<mask>
<mask> The most common reason is a typo or because you did not actually create an
<mask> ``app`` object.
<mask>
<mask> .. _debug-mode:
<mask>
<mask> Debug Mode
<mask> ----------
<mask>
<mask> (Want to just log errors and stack traces? See :doc:`errorhandling`)
</s> rewrite debugging docs, move to ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/89d1487b2ed0eb4fc4fb49a50eb54b942bec4193 | docs/quickstart.rst | |
The ``flask run`` command can do more than just start the development
server. By enabling debug mode, the server will automatically reload if
code changes, and will show an interactive debugger in the browser if an
error occurs during a request. | <mask>
<mask> Debug Mode
<mask> ----------
<mask>
<mask> (Want to just log errors and stack traces? See :doc:`errorhandling`)
<mask>
<mask> The :command:`flask` script is nice to start a local development server, but
<mask> you would have to restart it manually after each change to your code.
<mask> That is... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/89d1487b2ed0eb4fc4fb49a50eb54b942bec4193 | docs/quickstart.rst |
.. image:: _static/debugger.png
:align: center
:class: screenshot
:alt: The interactive debugger in action. | <mask> ----------
<mask>
<mask> (Want to just log errors and stack traces? See :doc:`errorhandling`)
<mask>
<mask> The :command:`flask` script is nice to start a local development server, but
<mask> you would have to restart it manually after each change to your code.
<mask> That is not very nice and Flask can... | [
"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/89d1487b2ed0eb4fc4fb49a50eb54b942bec4193 | docs/quickstart.rst |
.. warning:: | <mask> exporting ``FLASK_DEBUG=1``.
<mask>
<mask> There are more parameters that are explained in :doc:`/server`.
<mask>
<mask> .. admonition:: Attention
<mask>
<mask> Even though the interactive debugger does not work in forking environments
<mask> (which makes it nearly impossible to use on productio... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/89d1487b2ed0eb4fc4fb49a50eb54b942bec4193 | docs/quickstart.rst |
The debugger allows executing arbitrary Python code from the
browser. It is protected by a pin, but still represents a major
security risk. Do not run the development server or debugger in a
production environment. | <mask> There are more parameters that are explained in :doc:`/server`.
<mask>
<mask> .. admonition:: Attention
<mask>
<mask> Even though the interactive debugger does not work in forking environments
<mask> (which makes it nearly impossible to use on production servers), it still
<mask> allows the exe... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/89d1487b2ed0eb4fc4fb49a50eb54b942bec4193 | docs/quickstart.rst |
To enable all development features, set the ``FLASK_ENV`` environment
variable to ``development`` before calling ``flask run``. | <mask> (which makes it nearly impossible to use on production servers), it still
<mask> allows the execution of arbitrary code. This makes it a major security risk
<mask> and therefore it **must never be used on production machines**.
<mask>
<mask> Screenshot of the debugger in action:
<mask>
<mask> .... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/89d1487b2ed0eb4fc4fb49a50eb54b942bec4193 | docs/quickstart.rst |
.. code-block:: text | <mask> and therefore it **must never be used on production machines**.
<mask>
<mask> Screenshot of the debugger in action:
<mask>
<mask> .. image:: _static/debugger.png
<mask> :align: center
<mask> :class: screenshot
<mask> :alt: screenshot of debugger in action
<mask>
<mask> More information o... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/89d1487b2ed0eb4fc4fb49a50eb54b942bec4193 | docs/quickstart.rst |
$ export FLASK_ENV=development
$ flask run | <mask> :align: center
<mask> :class: screenshot
<mask> :alt: screenshot of debugger in action
<mask>
<mask> More information on using the debugger can be found in the `Werkzeug
<mask> documentation`_.
<mask>
<mask> .. _Werkzeug documentation: https://werkzeug.palletsprojects.com/debug/#using-the-debu... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/89d1487b2ed0eb4fc4fb49a50eb54b942bec4193 | docs/quickstart.rst |
See also: | <mask>
<mask> More information on using the debugger can be found in the `Werkzeug
<mask> documentation`_.
<mask>
<mask> .. _Werkzeug documentation: https://werkzeug.palletsprojects.com/debug/#using-the-debugger
<mask>
<mask> Have another debugger in mind? See :ref:`working-with-debuggers`.
<mask>
<mask>
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/89d1487b2ed0eb4fc4fb49a50eb54b942bec4193 | docs/quickstart.rst |
- :doc:`/server` and :doc:`/cli` for information about running in
development mode.
- :doc:`/debugging` for information about using the built-in debugger
and other debuggers.
- :doc:`/logging` and :doc:`/errorhandling` to log errors and display
nice error pages. | <mask> documentation`_.
<mask>
<mask> .. _Werkzeug documentation: https://werkzeug.palletsprojects.com/debug/#using-the-debugger
<mask>
<mask> Have another debugger in mind? See :ref:`working-with-debuggers`.
<mask>
<mask>
<mask> HTML Escaping
<mask> -------------
<mask>
</s> rewrite debugging docs, mov... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/89d1487b2ed0eb4fc4fb49a50eb54b942bec4193 | docs/quickstart.rst |
<mask> TOXENV: py,codecov
<mask>
<mask> matrix:
<mask> - PYTHON: C:\Python37-x64
<mask> - PYTHON: C:\Python36-x64
<mask> - PYTHON: C:\Python27-x64
<mask>
<mask> init:
<mask> - SET PATH=%PYTHON%;%PATH%
<mask>
</s> use specific pypy versions for travis xenial
remove 3.6 from appveyor, re... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8a14c6d67d09d2a27c1d4685415d8ab0d6448561 | .appveyor.yml | |
<mask> os: linux
<mask> dist: xenial
<mask> sudo: false
<mask> language: python
<mask>
<mask> matrix:
<mask> include:
<mask> - python: 3.7
</s> use specific pypy versions for travis xenial
remove 3.6 from appveyor, reduce in tox
remove deprecated travis feature "sudo: false"
split docs and devel,lowest ... | [
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8a14c6d67d09d2a27c1d4685415d8ab0d6448561 | .travis.yml | |
python:
- "3.7"
- "3.6"
- "3.5"
- "3.4"
- "2.7"
- nightly
- pypy3.5-6.0
env: TOXENV=py,codecov | <mask> dist: xenial
<mask> language: python
<mask>
<mask> matrix:
<mask> include:
<mask> - env: TOXENV=docs-html
</s> use specific pypy versions for travis xenial
remove 3.6 from appveyor, reduce in tox
remove deprecated travis feature "sudo: false"
split docs and devel,lowest travis envs
remove osx py2 e... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/8a14c6d67d09d2a27c1d4685415d8ab0d6448561 | .travis.yml |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.