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
To use the ``flask`` command and run your application you need to set the ``--app`` option that tells Flask where to find the application instance:
<mask> .. code-block:: text <mask> <mask> > $env:FLASK_ENV = "development" <mask> <mask> In order to install and run the application you need to issue the following <mask> commands:: <mask> <mask> $ pip install -e . <mask> $ flask run <mask> <mask> What did we gain from this? Now ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/patterns/packages.rst
$ flask --app yourapplication run
<mask> <mask> In order to install and run the application you need to issue the following <mask> commands:: <mask> <mask> $ pip install -e . <mask> $ flask run <mask> <mask> What did we gain from this? Now we can restructure the application a bit <mask> into multiple modules. The only thing you ha...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/patterns/packages.rst
To run the application, use the ``flask`` command or ``python -m flask``. You need to tell the Flask where your application is with the ``-app`` option.
<mask> Save it as :file:`hello.py` or something similar. Make sure to not call <mask> your application :file:`flask.py` because this would conflict with Flask <mask> itself. <mask> <mask> To run the application, use the :command:`flask` command or <mask> :command:`python -m flask`. Before you can do that you nee...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/quickstart.rst
.. code-block:: text
<mask> :command:`python -m flask`. Before you can do that you need <mask> to tell your terminal the application to work with by exporting the <mask> ``FLASK_APP`` environment variable: <mask> <mask> .. tabs:: <mask> <mask> .. group-tab:: Bash <mask> <mask> .. code-block:: text <mask> <mask> ...
[ "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/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/quickstart.rst
$ flask --app hello run * Serving Flask app 'hello' (lazy loading) * Running on http://127.0.0.1:5000 (Press CTRL+C to quit)
<mask> .. group-tab:: Powershell <mask> <mask> .. code-block:: text <mask> <mask> > $env:FLASK_APP = "hello" <mask> > flask run <mask> * Running on http://127.0.0.1:5000/ <mask> <mask> .. admonition:: Application Discovery Behavior <mask> <mask> As a shortcut, if ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/quickstart.rst
don't have to use ``--app``. See :doc:`/cli` for more details.
<mask> <mask> .. admonition:: Application Discovery Behavior <mask> <mask> As a shortcut, if the file is named ``app.py`` or ``wsgi.py``, you <mask> don't have to set the ``FLASK_APP`` environment variable. See <mask> :doc:`/cli` for more details. <mask> <mask> This launches a very simple builtin...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/quickstart.rst
<mask> <mask> This tells your operating system to listen on all public IPs. <mask> <mask> <mask> What to do if the Server does not Start <mask> --------------------------------------- <mask> <mask> In case the :command:`python -m flask` fails or :command:`flask` <mask> does not exist, there are multiple...
[ "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/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/quickstart.rst
To enable all development features, set the ``--env`` option to ``development``.
<mask> browser. It is protected by a pin, but still represents a major <mask> security risk. Do not run the development server or debugger in a <mask> production environment. <mask> <mask> To enable all development features, set the ``FLASK_ENV`` environment <mask> variable to ``development`` before ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/quickstart.rst
.. code-block:: text
<mask> <mask> $ export FLASK_ENV=development <mask> $ flask run <mask> <mask> .. group-tab:: Fish <mask> <mask> .. code-block:: text <mask> <mask> $ set -x FLASK_ENV development <mask> $ flask run <mask> <mask> .. group-tab:: CMD <mask> <mask> .....
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/quickstart.rst
$ flask --app hello --env development run * Serving Flask app 'hello' (lazy loading) * Environment: development * Debug mode: on * Running on http://127.0.0.1:5000 (Press CTRL+C to quit) * Restarting with stat * Debugger is active! * Debugger PIN: nnn-nnn-nnn
<mask> .. group-tab:: Powershell <mask> <mask> .. code-block:: text <mask> <mask> > $env:FLASK_ENV = "development" <mask> > flask run <mask> <mask> See also: <mask> <mask> - :doc:`/server` and :doc:`/cli` for information about running in <mask> development mode. </s> pre...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/quickstart.rst
``--env`` option is set to ``'development'``), the error and data will be preserved and shown in the interactive debugger.
<mask> associated with it is destroyed. If an error occurs during development, <mask> it is useful to delay destroying the data for debugging purposes. <mask> <mask> When the development server is running in development mode (the <mask> ``FLASK_ENV`` environment variable is set to ``'development'``), the <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/reqcontext.rst
development server. Use the ``--app`` option to point to your application, and the ``--env development`` option to fully enable development mode. .. code-block:: text $ flask --app hello --env development run These options (and any others) can also be set using environment variables.
<mask> Command Line <mask> ------------ <mask> <mask> The ``flask run`` command line script is the recommended way to run the <mask> development server. It requires setting the ``FLASK_APP`` environment <mask> variable to point to your application, and ``FLASK_ENV=development`` to <mask> fully enable developmen...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/server.rst
Debug mode can be controlled separately from the development environment with the ``--debug/--no-debug`` option or the ``FLASK_DEBUG`` environment variable. This is how older versions of Flask worked. You should prefer setting the development environment as shown above.
<mask> and using the CLI. <mask> <mask> .. note:: <mask> <mask> Prior to Flask 1.0 the ``FLASK_ENV`` environment variable was not <mask> supported and you needed to enable debug mode by exporting <mask> ``FLASK_DEBUG=1``. This can still be used to control debug mode, but <mask> you should pref...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/server.rst
and activate the env as described in :doc:`/installation`.
<mask> <mask> If you're still running the server from the previous page, you can <mask> either stop the server, or run this command in a new terminal. If <mask> you use a new terminal, remember to change to your project directory <mask> and activate the env as described in :doc:`/installation`. Yo...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/tutorial/database.rst
$ flask --app flaskr init-db
<mask> Run the ``init-db`` command: <mask> <mask> .. code-block:: none <mask> <mask> $ flask init-db <mask> Initialized the database. <mask> <mask> There will now be a ``flaskr.sqlite`` file in the ``instance`` folder in <mask> your project. <mask> </s> prefer --app over FLASK_APP in docs </s> re...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/tutorial/database.rst
.. code-block:: text
<mask> <mask> Since this is a different machine, you need to run ``init-db`` again to <mask> create the database in the instance folder. <mask> <mask> .. tabs:: <mask> <mask> .. group-tab:: Bash <mask> <mask> .. code-block:: text <mask> </s> prefer --app over FLASK_APP in docs </s> remove .....
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/tutorial/deploy.rst
$ flask --app flaskr init-db
<mask> create the database in the instance folder. <mask> <mask> .. tabs:: <mask> <mask> .. group-tab:: Bash <mask> <mask> .. code-block:: text <mask> <mask> $ export FLASK_APP=flaskr <mask> $ flask init-db <mask> <mask> .. group-tab:: Fish <mask> <mask> .. code-b...
[ "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/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/tutorial/deploy.rst
``--app`` like ``flask run`` does. You need to tell it to import and
<mask> <mask> $ pip install waitress <mask> <mask> You need to tell Waitress about your application, but it doesn't use <mask> ``FLASK_APP`` like ``flask run`` does. You need to tell it to import and <mask> call the application factory to get an application object. <mask> <mask> .. code-block:: none <ma...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/tutorial/deploy.rst
.. code-block:: text
<mask> exception, and restarts the server whenever you make changes to the <mask> code. You can leave it running and just reload the browser page as you <mask> follow the tutorial. <mask> <mask> .. tabs:: <mask> <mask> .. group-tab:: Bash <mask> <mask> .. code-block:: text <mask> </s> prefer --a...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/tutorial/factory.rst
$ flask --app flaskr --env development run
<mask> follow the tutorial. <mask> <mask> .. tabs:: <mask> <mask> .. group-tab:: Bash <mask> <mask> .. code-block:: text <mask> <mask> $ export FLASK_APP=flaskr <mask> $ export FLASK_ENV=development <mask> $ flask run <mask> <mask> .. group-tab:: Fish <mask> <...
[ "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/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/tutorial/factory.rst
.. code-block:: text
<mask> > flask run <mask> <mask> You'll see output similar to this: <mask> <mask> .. code-block:: none <mask> <mask> * Serving Flask app "flaskr" <mask> * Environment: development <mask> * Debug mode: on <mask> * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) </s> pr...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/tutorial/factory.rst
* Debugger PIN: nnn-nnn-nnn
<mask> * Debug mode: on <mask> * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) <mask> * Restarting with stat <mask> * Debugger is active! <mask> * Debugger PIN: 855-212-761 <mask> <mask> Visit http://127.0.0.1:5000/hello in a browser and you should see the <mask> "Hello, Wor...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/tutorial/factory.rst
``--app`` is still set to ``flaskr`` and ``flask run`` still runs
<mask> Werkzeug 0.14.1 <mask> wheel 0.30.0 <mask> <mask> Nothing changes from how you've been running your project so far. <mask> ``FLASK_APP`` is still set to ``flaskr`` and ``flask run`` still runs <mask> the application, but you can call it from anywhere, not just the <mask> ``flask-tu...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
docs/tutorial/install.rst
$ flask --app js_example run
<mask> --- <mask> <mask> .. code-block:: text <mask> <mask> $ export FLASK_APP=js_example <mask> $ flask run <mask> <mask> Open http://127.0.0.1:5000 in a browser. <mask> <mask> <mask> Test </s> prefer --app over FLASK_APP in docs </s> remove > set FLASK_APP=flaskr > set FLASK_ENV=devel...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
examples/javascript/README.rst
.. code-block:: text
<mask> <mask> Run <mask> --- <mask> <mask> :: <mask> <mask> $ export FLASK_APP=flaskr <mask> $ export FLASK_ENV=development <mask> $ flask init-db <mask> $ flask run <mask> <mask> Or on Windows cmd:: <mask> <mask> > set FLASK_APP=flaskr <mask> > set FLASK_ENV=development <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
examples/tutorial/README.rst
$ flask --app flaskr init-db $ flask --app flaskr --env development run
<mask> $ flask run <mask> <mask> Or on Windows cmd:: <mask> <mask> > set FLASK_APP=flaskr <mask> > set FLASK_ENV=development <mask> > flask init-db <mask> > flask run <mask> <mask> Open http://127.0.0.1:5000 in a browser. <mask> <mask> <mask> Test </s> prefer --app over FLASK_APP ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
examples/tutorial/README.rst
(os.environ, "FLASK_ENV_FILE", monkeypatch.notset),
<mask> :func:`._reset_os_environ` after each test. <mask> """ <mask> mp = monkeypatch.MonkeyPatch() <mask> out = ( <mask> (os.environ, "FLASK_APP", monkeypatch.notset), <mask> (os.environ, "FLASK_ENV", monkeypatch.notset), <mask> (os.environ, "FLASK_DEBUG", monkeypatch.not...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506
tests/conftest.py
- :func:`request.get_json <flask.Request.get_json>` no longer accepts arbitrary encodings. Incoming JSON should be encoded using UTF-8 per :rfc:`8259`, but Flask will autodetect UTF-8, -16, or -32. (`#2691`_)
<mask> - A single trailing slash is stripped from the blueprint ``url_prefix`` <mask> when it is registered with the app. (`#2629`_) <mask> - :meth:`Request.get_json() <flask.Request.get_json>` doesn't cache the <mask> result if parsing fails when ``silent`` is true. (`#2651`_) <mask> <mask> .. _pallets/meta...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab4142215d836b0298fc47fa1e4b75408b9c37a0
CHANGES.rst
.. _#2691: https://github.com/pallets/flask/pull/2691
<mask> .. _#2636: https://github.com/pallets/flask/pull/2636 <mask> .. _#2635: https://github.com/pallets/flask/pull/2635 <mask> .. _#2629: https://github.com/pallets/flask/pull/2629 <mask> .. _#2651: https://github.com/pallets/flask/issues/2651 <mask> <mask> <mask> Version 0.12.2 <mask> -------------- </s> ...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab4142215d836b0298fc47fa1e4b75408b9c37a0
CHANGES.rst
encoding = kwargs.pop('encoding', None) if encoding is None: encoding = detect_encoding(s) s = s.decode(encoding)
<mask> application on the stack. <mask> """ <mask> _load_arg_defaults(kwargs) <mask> if isinstance(s, bytes): <mask> s = s.decode(kwargs.pop('encoding', None) or 'utf-8') <mask> return _json.loads(s, **kwargs) <mask> <mask> <mask> def load(fp, **kwargs): <mask> """Like :func:...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab4142215d836b0298fc47fa1e4b75408b9c37a0
flask/json/__init__.py
"""Parse and return the data as JSON. If the mimetype does not indicate JSON (:mimetype:`application/json`, see :meth:`is_json`), this returns ``None`` unless ``force`` is true. If parsing fails, :meth:`on_json_loading_failed` is called and its return value is used as the return ...
<mask> def _get_data_for_json(self, cache): <mask> return self.get_data(cache=cache) <mask> <mask> def get_json(self, force=False, silent=False, cache=True): <mask> """Parse and return the data as JSON. If the mimetype does not indicate <mask> JSON (:mimetype:`application/json`, s...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab4142215d836b0298fc47fa1e4b75408b9c37a0
flask/wrappers.py
:param silent: Silence parsing errors and return ``None`` instead. :param cache: Store the parsed JSON to return for subsequent calls.
<mask> :meth:`on_json_loading_failed` is called and its return value is used <mask> as the return value. <mask> <mask> :param force: Ignore the mimetype and always try to parse JSON. <mask> :param silent: Silence parsing errors and return ``None`` instead. <mask> :param ca...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab4142215d836b0298fc47fa1e4b75408b9c37a0
flask/wrappers.py
data = self._get_data_for_json(cache=cache)
<mask> <mask> if not (force or self.is_json): <mask> return None <mask> <mask> # We accept MIME charset against the specification as certain clients <mask> # have used this in the past. For responses, we assume that if the <mask> # charset is set then the data has be...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab4142215d836b0298fc47fa1e4b75408b9c37a0
flask/wrappers.py
rv = json.loads(data)
<mask> # charset is set then the data has been encoded correctly as well. <mask> charset = self.mimetype_params.get('charset') <mask> <mask> try: <mask> data = self._get_data_for_json(cache=cache) <mask> rv = json.loads(data, encoding=charset) <mask> excep...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab4142215d836b0298fc47fa1e4b75408b9c37a0
flask/wrappers.py
from werkzeug.http import ( http_date, parse_cache_control_header,
<mask> <mask> import pytest <mask> from werkzeug.datastructures import Range <mask> from werkzeug.exceptions import BadRequest, NotFound <mask> from werkzeug.http import http_date, parse_cache_control_header, \ <mask> parse_options_header <mask> <mask> import flask <mask> from flask._compat import String...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab4142215d836b0298fc47fa1e4b75408b9c37a0
tests/test_helpers.py
)
<mask> from werkzeug.http import ( <mask> http_date, parse_cache_control_header, <mask> parse_options_header <mask> <mask> import flask <mask> from flask import json <mask> from flask._compat import StringIO, text_type <mask> from flask.helpers import get_debug_flag, get_env </s> detect UTF encodings ...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab4142215d836b0298fc47fa1e4b75408b9c37a0
tests/test_helpers.py
from flask import json
<mask> ) <mask> <mask> import flask <mask> from flask._compat import StringIO, text_type <mask> from flask.helpers import get_debug_flag, get_env <mask> <mask> </s> detect UTF encodings when loading json </s> remove from werkzeug.http import http_date, parse_cache_control_header, \ </s> add from werkzeug.ht...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab4142215d836b0298fc47fa1e4b75408b9c37a0
tests/test_helpers.py
def app(self): app = Flask(__name__) app.testing = True
<mask> <mask> <mask> class TestRoutes: <mask> @pytest.fixture <mask> def invoke(self, runner): <mask> def create_app(): <mask> app = Flask(__name__) <mask> app.testing = True <mask> <mask> @app.route("/get_post/<int:x>/<int:y>", methods=["GET", "POST"]) ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab6a8b0330845c80d661a748314691302ea7d8f7
tests/test_cli.py
@app.route("/get_post/<int:x>/<int:y>", methods=["GET", "POST"]) def yyy_get_post(x, y): pass
<mask> def create_app(): <mask> app = Flask(__name__) <mask> app.testing = True <mask> <mask> @app.route("/get_post/<int:x>/<int:y>", methods=["GET", "POST"]) <mask> def yyy_get_post(x, y): <mask> pass <mask> <mask> @app.rout...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab6a8b0330845c80d661a748314691302ea7d8f7
tests/test_cli.py
@app.route("/zzz_post", methods=["POST"]) def aaa_post(): pass
<mask> @app.route("/get_post/<int:x>/<int:y>", methods=["GET", "POST"]) <mask> def yyy_get_post(x, y): <mask> pass <mask> <mask> @app.route("/zzz_post", methods=["POST"]) <mask> def aaa_post(): <mask> pass <mask> <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab6a8b0330845c80d661a748314691302ea7d8f7
tests/test_cli.py
return app
<mask> @app.route("/zzz_post", methods=["POST"]) <mask> def aaa_post(): <mask> pass <mask> <mask> return app <mask> <mask> cli = FlaskGroup(create_app=create_app) <mask> return partial(runner.invoke, cli) <mask> <mask> @pytest.fixture ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab6a8b0330845c80d661a748314691302ea7d8f7
tests/test_cli.py
@pytest.fixture def invoke(self, app, runner): cli = FlaskGroup(create_app=lambda: app)
<mask> pass <mask> <mask> return app <mask> <mask> cli = FlaskGroup(create_app=create_app) <mask> return partial(runner.invoke, cli) <mask> <mask> @pytest.fixture <mask> def invoke_no_routes(self, runner): <mask> def create_app(): </s> relax rout...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab6a8b0330845c80d661a748314691302ea7d8f7
tests/test_cli.py
def test_sort(self, app, invoke):
<mask> result = invoke(["routes"]) <mask> assert result.exit_code == 0 <mask> self.expect_order(["aaa_post", "static", "yyy_get_post"], result.output) <mask> <mask> def test_sort(self, invoke): <mask> default_output = invoke(["routes"]).output <mask> endpoint_output =...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab6a8b0330845c80d661a748314691302ea7d8f7
tests/test_cli.py
match_order = [r.endpoint for r in app.url_map.iter_rules()] self.expect_order(match_order, invoke(["routes", "-s", "match"]).output)
<mask> self.expect_order( <mask> ["yyy_get_post", "static", "aaa_post"], <mask> invoke(["routes", "-s", "rule"]).output, <mask> ) <mask> self.expect_order( <mask> ["aaa_post", "yyy_get_post", "static"], <mask> invoke(["routes", "-s", "match"...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab6a8b0330845c80d661a748314691302ea7d8f7
tests/test_cli.py
"""Register a URL rule with the blueprint. See :meth:`.Flask.add_url_rule` for full documentation. The URL rule is prefixed with the blueprint's URL prefix. The endpoint name, used with :func:`url_for`, is prefixed with the blueprint's name.
<mask> view_func: t.Optional[ft.RouteCallable] = None, <mask> provide_automatic_options: t.Optional[bool] = None, <mask> **options: t.Any, <mask> ) -> None: <mask> """Like :meth:`Flask.add_url_rule` but for a blueprint. The endpoint for <mask> the :func:`url_for` funct...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/blueprints.py
"""Register a template filter, available in any template rendered by the application. Equivalent to :meth:`.Flask.template_filter`.
<mask> @setupmethod <mask> def app_template_filter( <mask> self, name: t.Optional[str] = None <mask> ) -> t.Callable[[T_template_filter], T_template_filter]: <mask> """Register a custom template filter, available application wide. Like <mask> :meth:`Flask.template_filter` but ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/blueprints.py
"""Register a template filter, available in any template rendered by the application. Works like the :meth:`app_template_filter` decorator. Equivalent to :meth:`.Flask.add_template_filter`.
<mask> @setupmethod <mask> def add_app_template_filter( <mask> self, f: ft.TemplateFilterCallable, name: t.Optional[str] = None <mask> ) -> None: <mask> """Register a custom template filter, available application wide. Like <mask> :meth:`Flask.add_template_filter` but for a bl...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/blueprints.py
"""Register a template test, available in any template rendered by the application. Equivalent to :meth:`.Flask.template_test`.
<mask> @setupmethod <mask> def app_template_test( <mask> self, name: t.Optional[str] = None <mask> ) -> t.Callable[[T_template_test], T_template_test]: <mask> """Register a custom template test, available application wide. Like <mask> :meth:`Flask.template_test` but for a blue...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/blueprints.py
"""Register a template test, available in any template rendered by the application. Works like the :meth:`app_template_test` decorator. Equivalent to :meth:`.Flask.add_template_test`.
<mask> @setupmethod <mask> def add_app_template_test( <mask> self, f: ft.TemplateTestCallable, name: t.Optional[str] = None <mask> ) -> None: <mask> """Register a custom template test, available application wide. Like <mask> :meth:`Flask.add_template_test` but for a blueprint....
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/blueprints.py
"""Register a template global, available in any template rendered by the application. Equivalent to :meth:`.Flask.template_global`.
<mask> @setupmethod <mask> def app_template_global( <mask> self, name: t.Optional[str] = None <mask> ) -> t.Callable[[T_template_global], T_template_global]: <mask> """Register a custom template global, available application wide. Like <mask> :meth:`Flask.template_global` but ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/blueprints.py
"""Register a template global, available in any template rendered by the application. Works like the :meth:`app_template_global` decorator. Equivalent to :meth:`.Flask.add_template_global`.
<mask> @setupmethod <mask> def add_app_template_global( <mask> self, f: ft.TemplateGlobalCallable, name: t.Optional[str] = None <mask> ) -> None: <mask> """Register a custom template global, available application wide. Like <mask> :meth:`Flask.add_template_global` but for a bl...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/blueprints.py
"""Like :meth:`before_request`, but before every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.before_request`.
<mask> self.record_once(register_template) <mask> <mask> @setupmethod <mask> def before_app_request(self, f: T_before_request) -> T_before_request: <mask> """Like :meth:`Flask.before_request`. Such a function is executed <mask> before each request, even if outside of a blueprint....
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/blueprints.py
"""Register a function to run before the first request to the application is handled by the worker. Equivalent to :meth:`.Flask.before_first_request`.
<mask> @setupmethod <mask> def before_app_first_request( <mask> self, f: T_before_first_request <mask> ) -> T_before_first_request: <mask> """Like :meth:`Flask.before_first_request`. Such a function is <mask> executed before the first request to the application. <mask> <mas...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/blueprints.py
"""Like :meth:`after_request`, but after every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.after_request`.
<mask> return f <mask> <mask> @setupmethod <mask> def after_app_request(self, f: T_after_request) -> T_after_request: <mask> """Like :meth:`Flask.after_request` but for a blueprint. Such a function <mask> is executed after each request, even if outside of the blueprint. <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/blueprints.py
"""Like :meth:`teardown_request`, but after every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.teardown_request`.
<mask> return f <mask> <mask> @setupmethod <mask> def teardown_app_request(self, f: T_teardown) -> T_teardown: <mask> """Like :meth:`Flask.teardown_request` but for a blueprint. Such a <mask> function is executed when tearing down each request, even if outside of <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/blueprints.py
"""Like :meth:`context_processor`, but for templates rendered by every view, not only by the blueprint. Equivalent to :meth:`.Flask.context_processor`.
<mask> @setupmethod <mask> def app_context_processor( <mask> self, f: T_template_context_processor <mask> ) -> T_template_context_processor: <mask> """Like :meth:`Flask.context_processor` but for a blueprint. Such a <mask> function is executed each request, even if outside of ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/blueprints.py
"""Like :meth:`errorhandler`, but for every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.errorhandler`.
<mask> @setupmethod <mask> def app_errorhandler( <mask> self, code: t.Union[t.Type[Exception], int] <mask> ) -> t.Callable[[T_error_handler], T_error_handler]: <mask> """Like :meth:`Flask.errorhandler` but for a blueprint. This <mask> handler is used for all requests, even if ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/blueprints.py
"""Like :meth:`url_value_preprocessor`, but for every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.url_value_preprocessor`. """
<mask> @setupmethod <mask> def app_url_value_preprocessor( <mask> self, f: T_url_value_preprocessor <mask> ) -> T_url_value_preprocessor: <mask> """Same as :meth:`url_value_preprocessor` but application wide.""" <mask> self.record_once( <mask> lambda s: s.app.url_v...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/blueprints.py
"""Like :meth:`url_defaults`, but for every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.url_defaults`. """
<mask> return f <mask> <mask> @setupmethod <mask> def app_url_defaults(self, f: T_url_defaults) -> T_url_defaults: <mask> """Same as :meth:`url_defaults` but application wide.""" <mask> self.record_once( <mask> lambda s: s.app.url_default_functions.setdefault(None, []...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/blueprints.py
This is available on both app and blueprint objects. When used on an app, this executes before every request. When used on a blueprint, this executes before every request that the blueprint handles. To register with a blueprint and execute before every request, use :meth:`.Blueprint.befo...
<mask> return value from the view, and further request handling is <mask> stopped. <mask> """ <mask> self.before_request_funcs.setdefault(None, []).append(f) <mask> return f <mask> <mask> @setupmethod <mask> def after_request(self, f: T_after_request) -> T_after_...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/scaffold.py
This is available on both app and blueprint objects. When used on an app, this executes after every request. When used on a blueprint, this executes after every request that the blueprint handles. To register with a blueprint and execute after every request, use :meth:`.Blueprint.after_a...
<mask> If a function raises an exception, any remaining <mask> ``after_request`` functions will not be called. Therefore, this <mask> should not be used for actions that must execute, such as to <mask> close resources. Use :meth:`teardown_request` for that. <mask> """ <mask...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/scaffold.py
This is available on both app and blueprint objects. When used on an app, this executes after every request. When used on a blueprint, this executes after every request that the blueprint handles. To register with a blueprint and execute after every request, use :meth:`.Blueprint.teardow...
<mask> execute code that might fail they must surround that code with a <mask> ``try``/``except`` block and log any errors. <mask> <mask> The return values of teardown functions are ignored. <mask> """ <mask> self.teardown_request_funcs.setdefault(None, []).append(f) <mas...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/scaffold.py
"""Registers a template context processor function. These functions run before rendering a template. The keys of the returned dict are added as variables available in the template. This is available on both app and blueprint objects. When used on an app, this is called for every...
<mask> def context_processor( <mask> self, <mask> f: T_template_context_processor, <mask> ) -> T_template_context_processor: <mask> """Registers a template context processor function.""" <mask> self.template_context_processors[None].append(f) <mask> return f <mask...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/scaffold.py
This is available on both app and blueprint objects. When used on an app, this is called for every request. When used on a blueprint, this is called for requests that the blueprint handles. To register with a blueprint and affect every request, use :meth:`.Blueprint.app_url_value_preproc...
<mask> every view. <mask> <mask> The function is passed the endpoint name and values dict. The return <mask> value is ignored. <mask> """ <mask> self.url_value_preprocessors[None].append(f) <mask> return f <mask> <mask> @setupmethod <mask> def url_defa...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/scaffold.py
This is available on both app and blueprint objects. When used on an app, this is called for every request. When used on a blueprint, this is called for requests that the blueprint handles. To register with a blueprint and affect every request, use :meth:`.Blueprint.app_url_defaults`.
<mask> """Callback function for URL defaults for all view functions of the <mask> application. It's called with the endpoint and values and should <mask> update the values passed in place. <mask> """ <mask> self.url_default_functions[None].append(f) <mask> return f...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/scaffold.py
This is available on both app and blueprint objects. When used on an app, this can handle errors from every request. When used on a blueprint, this can handle errors from requests that the blueprint handles. To register with a blueprint and affect every request, use :meth:`.Blueprint.app...
<mask> def special_exception_handler(error): <mask> return 'Database connection failed', 500 <mask> <mask> .. versionadded:: 0.7 <mask> Use :meth:`register_error_handler` instead of modifying <mask> :attr:`error_handler_spec` directly, for application w...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ab93222bd6d4ea26e3aa832a0409489530f3f5e0
src/flask/scaffold.py
<mask> implements_to_string = _identity <mask> encode_filename = _identity <mask> get_next = lambda x: x.__next__ <mask> <mask> from urllib.parse import urlparse <mask> <mask> else: <mask> unichr = unichr <mask> text_type = unicode <mask> range_type = xrange <mask> string_ty...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abc1505196ba3bc9517ec142ced7c1204c3ac21b
flask/_compat.py
<mask> if isinstance(filename, unicode): <mask> return filename.encode('utf-8') <mask> return filename <mask> <mask> from urlparse import urlparse <mask> <mask> <mask> def with_metaclass(meta, *bases): <mask> # This requires a bit of explanation: the basic idea is to make...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abc1505196ba3bc9517ec142ced7c1204c3ac21b
flask/_compat.py
import io
<mask> <mask> :copyright: (c) 2012 by Armin Ronacher. <mask> :license: BSD, see LICENSE for more details. <mask> """ <mask> import uuid <mask> from datetime import datetime <mask> from .globals import current_app, request <mask> from ._compat import text_type, PY2 <mask> </s> Fixed various issues on...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abc1505196ba3bc9517ec142ced7c1204c3ac21b
flask/json.py
from ._compat import text_type, PY2
<mask> """ <mask> import uuid <mask> from datetime import datetime <mask> from .globals import current_app, request <mask> from ._compat import text_type <mask> <mask> from werkzeug.http import http_date <mask> <mask> # Use the same json implementation as itsdangerous on which we <mask> # depend anyways. <...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abc1505196ba3bc9517ec142ced7c1204c3ac21b
flask/json.py
def _wrap_reader_for_text(fp, encoding): if isinstance(fp.read(0), bytes): fp = io.TextIOWrapper(io.BufferedReader(fp), encoding) return fp def _wrap_writer_for_text(fp, encoding): try: fp.write('') except TypeError: fp = io.TextIOWrapper(fp, encoding) return fp
<mask> <mask> <mask> class JSONEncoder(_json.JSONEncoder): <mask> """The default Flask JSON encoder. This one extends the default simplejson <mask> encoder by also supporting ``datetime`` objects, ``UUID`` as well as <mask> ``Markup`` objects which are serialized as RFC 822 datetime strings (same ...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abc1505196ba3bc9517ec142ced7c1204c3ac21b
flask/json.py
encoding = kwargs.pop('encoding', None) rv = _json.dumps(obj, **kwargs) if encoding is not None and isinstance(rv, text_type): rv = rv.encode(encoding) return rv
<mask> default is controlled by the ``JSON_AS_ASCII`` configuration variable <mask> and can be overriden by the simplejson ``ensure_ascii`` parameter. <mask> """ <mask> _dump_arg_defaults(kwargs) <mask> return _json.dumps(obj, **kwargs) <mask> <mask> <mask> def dump(obj, fp, **kwargs): <m...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abc1505196ba3bc9517ec142ced7c1204c3ac21b
flask/json.py
encoding = kwargs.pop('encoding', None) if encoding is not None: fp = _wrap_writer_for_text(fp, encoding) _json.dump(obj, fp, **kwargs)
<mask> <mask> def dump(obj, fp, **kwargs): <mask> """Like :func:`dumps` but writes into a file object.""" <mask> _dump_arg_defaults(kwargs) <mask> return _json.dump(obj, fp, **kwargs) <mask> <mask> <mask> def loads(s, **kwargs): <mask> """Unserialize a JSON object from a string ``s`` by usin...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abc1505196ba3bc9517ec142ced7c1204c3ac21b
flask/json.py
if isinstance(s, bytes): s = s.decode(kwargs.pop('encoding', None) or 'utf-8')
<mask> """ <mask> _load_arg_defaults(kwargs) <mask> return _json.loads(s, **kwargs) <mask> <mask> <mask> def load(fp, **kwargs): <mask> """Like :func:`loads` but reads from a file object. <mask> """ </s> Fixed various issues on the Python 3 port </s> remove return _json.dump(obj, fp, ...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abc1505196ba3bc9517ec142ced7c1204c3ac21b
flask/json.py
if not PY2: fp = _wrap_reader_for_text(fp, kwargs.pop('encoding', None) or 'utf-8')
<mask> """Like :func:`loads` but reads from a file object. <mask> """ <mask> _load_arg_defaults(kwargs) <mask> return _json.load(fp, **kwargs) <mask> <mask> <mask> def htmlsafe_dumps(obj, **kwargs): </s> Fixed various issues on the Python 3 port </s> remove return _json.dump(obj, fp, **kwa...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abc1505196ba3bc9517ec142ced7c1204c3ac21b
flask/json.py
try: from werkzeug.urls import url_parse except ImportError: from urlparse import urlsplit as url_parse
<mask> <mask> from contextlib import contextmanager <mask> from werkzeug.test import Client, EnvironBuilder <mask> from flask import _request_ctx_stack <mask> from ._compat import urlparse <mask> <mask> <mask> def make_test_environ_builder(app, path='/', base_url=None, *args, **kwargs): <mask> """Create...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abc1505196ba3bc9517ec142ced7c1204c3ac21b
flask/testing.py
url = url_parse(path)
<mask> """Creates a new test builder with some application defaults thrown in.""" <mask> http_host = app.config.get('SERVER_NAME') <mask> app_root = app.config.get('APPLICATION_ROOT') <mask> if base_url is None: <mask> url = urlparse(path) <mask> base_url = 'http://%s/' % (url.netl...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abc1505196ba3bc9517ec142ced7c1204c3ac21b
flask/testing.py
static_folder='static', template_folder='templates'): _PackageBoundObject.__init__(self, import_name, template_folder=template_folder)
<mask> #: .. versionadded:: 0.7 <mask> test_client_class = None <mask> <mask> def __init__(self, import_name, static_path=None, static_url_path=None, <mask> static_folder='static'): <mask> _PackageBoundObject.__init__(self, import_name) <mask> if static_path is not N...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abe1378caec759cc8c6fc0afeaad248677c4420f
flask/app.py
def create_global_jinja_loader(self):
<mask> ) <mask> rv.filters['tojson'] = _tojson_filter <mask> return rv <mask> <mask> def create_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. <mask> <mask...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abe1378caec759cc8c6fc0afeaad248677c4420f
flask/app.py
static_url_path=None, template_folder=None, url_prefix=None, subdomain=None): _PackageBoundObject.__init__(self, import_name, template_folder)
<mask> warn_on_modifications = False <mask> _got_registered_once = False <mask> <mask> def __init__(self, name, import_name, static_folder=None, <mask> static_url_path=None, url_prefix=None, <mask> subdomain=None): <mask> _PackageBoundObject.__init__(self, i...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abe1378caec759cc8c6fc0afeaad248677c4420f
flask/blueprints.py
def __init__(self, import_name, template_folder=None):
<mask> <mask> <mask> class _PackageBoundObject(object): <mask> <mask> template_folder = 'templates' <mask> <mask> def __init__(self, import_name): <mask> #: The name of the package or module. Do not change this once <mask> #: it was set by the constructor. <mask> self.impo...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abe1378caec759cc8c6fc0afeaad248677c4420f
flask/helpers.py
#: location of the templates. `None` if templates should not be #: exposed. self.template_folder = template_folder
<mask> self.import_name = import_name <mask> <mask> #: Where is the app root located? <mask> self.root_path = _get_package_path(self.import_name) <mask> <mask> self._static_folder = None </s> Chnaged a bunch of behavior in blueprints for it to be more flexible. Improved backward...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abe1378caec759cc8c6fc0afeaad248677c4420f
flask/helpers.py
return send_from_directory(self.static_folder, filename)
<mask> .. versionadded:: 0.5 <mask> """ <mask> if not self.has_static_folder: <mask> raise RuntimeError('No static folder for this object') <mask> return send_from_directory(os.path.join(self.root_path, 'static'), <mask> filename) <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abe1378caec759cc8c6fc0afeaad248677c4420f
flask/helpers.py
<mask> """ <mask> <mask> import os <mask> <mask> from .helpers import _PackageBoundObject, _endpoint_from_view_func <mask> from .blueprints import Blueprint <mask> <mask> <mask> def blueprint_is_module(bp): <mask> """Used to figure out if something is actually a module""" </s> Chnaged a bunch of beha...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abe1378caec759cc8c6fc0afeaad248677c4420f
flask/module.py
subdomain=subdomain, template_folder='templates')
<mask> assert '.' in import_name, 'name required if package name ' \ <mask> 'does not point to a submodule' <mask> name = import_name.rsplit('.', 1)[1] <mask> Blueprint.__init__(self, name, import_name, url_prefix=url_prefix, <mask> subdoma...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abe1378caec759cc8c6fc0afeaad248677c4420f
flask/module.py
options['loader'] = app.create_global_jinja_loader()
<mask> """ <mask> <mask> def __init__(self, app, **options): <mask> if 'loader' not in options: <mask> options['loader'] = app.create_jinja_loader() <mask> BaseEnvironment.__init__(self, **options) <mask> self.app = app <mask> <mask> def join_path(self, templat...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abe1378caec759cc8c6fc0afeaad248677c4420f
flask/templating.py
<mask> options['loader'] = app.create_jinja_loader() <mask> BaseEnvironment.__init__(self, **options) <mask> self.app = app <mask> <mask> def join_path(self, template, parent): <mask> if template and template[0] == ':': <mask> template = parent.split(':', 1)[0...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abe1378caec759cc8c6fc0afeaad248677c4420f
flask/templating.py
the blueprint folders.
<mask> <mask> <mask> class DispatchingJinjaLoader(BaseLoader): <mask> """A loader that looks for templates in the application and all <mask> the module folders. <mask> """ <mask> <mask> def __init__(self, app): <mask> self.app = app <mask> </s> Chnaged a bunch of behavior in bluep...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abe1378caec759cc8c6fc0afeaad248677c4420f
flask/templating.py
for loader, local_name in self._iter_loaders(template): try: return loader.get_source(environment, local_name) except TemplateNotFound: pass raise TemplateNotFound(template)
<mask> def __init__(self, app): <mask> self.app = app <mask> <mask> def get_source(self, environment, template): <mask> # newstyle template support. blueprints are explicit and no further <mask> # magic is involved. If the template cannot be loaded by the <mask> # bluep...
[ "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/abe1378caec759cc8c6fc0afeaad248677c4420f
flask/templating.py
def _iter_loaders(self, template): loader = self.app.jinja_loader if loader is not None: yield loader, template # old style module based loaders in case we are dealing with a # blueprint that is an old style module
<mask> loader = blueprint.jinja_loader <mask> if loader is not None: <mask> return loader.get_source(environment, local_template) <mask> <mask> # if modules are enabled we call into the old style template lookup <mask> # and try that before we go with the r...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abe1378caec759cc8c6fc0afeaad248677c4420f
flask/templating.py
module, local_name = posixpath.normpath(template).split('/', 1)
<mask> # if modules are enabled we call into the old style template lookup <mask> # and try that before we go with the real deal. <mask> loader = None <mask> try: <mask> module, name = posixpath.normpath(template).split('/', 1) <mask> blueprint = self.app.bl...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abe1378caec759cc8c6fc0afeaad248677c4420f
flask/templating.py
if loader is not None: yield loader, local_name except (ValueError, KeyError):
<mask> module, name = posixpath.normpath(template).split('/', 1) <mask> blueprint = self.app.blueprints[module] <mask> if blueprint_is_module(blueprint): <mask> loader = blueprint.jinja_loader <mask> except (ValueError, KeyError, TemplateNotFound): <mask...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abe1378caec759cc8c6fc0afeaad248677c4420f
flask/templating.py
for blueprint in self.app.blueprints.itervalues(): loader = blueprint.jinja_loader if loader is not None: yield loader, template
<mask> return loader.get_source(environment, name) <mask> except TemplateNotFound: <mask> pass <mask> <mask> # at the very last, load templates from the environment <mask> return self.app.jinja_loader.get_source(environment, template) <mask> <mask> def l...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abe1378caec759cc8c6fc0afeaad248677c4420f
flask/templating.py
result = set() loader = self.app.jinja_loader if loader is not None: result.update(loader.list_templates())
<mask> # at the very last, load templates from the environment <mask> return self.app.jinja_loader.get_source(environment, template) <mask> <mask> def list_templates(self): <mask> result = set(self.app.jinja_loader.list_templates()) <mask> <mask> for name, module in self.app...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abe1378caec759cc8c6fc0afeaad248677c4420f
flask/templating.py
loader = blueprint.jinja_loader if loader is not None: for template in loader.list_templates(): prefix = '' if not blueprint_is_module(blueprint): prefix = name + '/' result.add(prefix + template)
<mask> for template in module.jinja_loader.list_templates(): <mask> result.add('%s/%s' % (name, template)) <mask> <mask> for name, blueprint in self.app.blueprints.iteritems(): <mask> if blueprint.jinja_loader is not None: <mask> for templat...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abe1378caec759cc8c6fc0afeaad248677c4420f
flask/templating.py
def create_global_jinja_loader(self):
<mask> assert rv.data == 'dcba' <mask> <mask> def test_custom_template_loader(self): <mask> class MyFlask(flask.Flask): <mask> def create_jinja_loader(self): <mask> from jinja2 import DictLoader <mask> return DictLoader({'index.html': 'Hello Custom...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/abe1378caec759cc8c6fc0afeaad248677c4420f
tests/flask_tests.py
1 // 0
<mask> except: <mask> pass <mask> @app.route('/') <mask> def fails(): <mask> 1/0 <mask> rv = app.test_client().get('/') <mask> self.assert_equal(rv.status_code, 500) <mask> self.assert_in(b'Internal Server Error', rv.data) <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ac04bc78361d5562f8289e8efe16a2e9a97b0d01
flask/testsuite/basic.py
1 // 0
<mask> def apprunner(configkey): <mask> app = flask.Flask(__name__) <mask> @app.route('/') <mask> def index(): <mask> 1/0 <mask> c = app.test_client() <mask> if config_key is not None: <mask> app.config[config_ke...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ac04bc78361d5562f8289e8efe16a2e9a97b0d01
flask/testsuite/basic.py
1 // 0
<mask> app.debug = True <mask> <mask> @app.route('/fail') <mask> def fail_func(): <mask> 1/0 <mask> <mask> c = app.test_client() <mask> for x in range(3): <mask> with self.assert_raises(ZeroDivisionError): <mask> c.get('/fail') ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ac04bc78361d5562f8289e8efe16a2e9a97b0d01
flask/testsuite/basic.py
1 // 0
<mask> return '' <mask> <mask> @app.route('/exc') <mask> def exc(): <mask> 1/0 <mask> <mask> with app.test_client() as c: <mask> with catch_stderr() as err: <mask> c.get('/') <mask> out = err.getvalue() </s> replace...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/ac04bc78361d5562f8289e8efe16a2e9a97b0d01
flask/testsuite/helpers.py