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
Windows CMD, :file:`.venv\\Scripts\\activate.bat`::
<mask> $ set -x FLASK_APP hello <mask> <mask> .. group-tab:: CMD <mask> <mask> Windows CMD, :file:`venv\\Scripts\\activate.bat`:: <mask> <mask> > set FLASK_APP=hello <mask> <mask> .. group-tab:: Powershell <mask> </s> update docs and examples for pyproject setup.py -> py...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/cli.rst
Windows Powershell, :file:`.venv\\Scripts\\activate.ps1`::
<mask> > set FLASK_APP=hello <mask> <mask> .. group-tab:: Powershell <mask> <mask> Windows Powershell, :file:`venv\\Scripts\\activate.ps1`:: <mask> <mask> > $env:FLASK_APP = "hello" <mask> <mask> It is preferred to use dotenv support over this, since :file:`.flaskenv` can be <...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/cli.rst
they are installed. Entry points are specified in :file:`pyproject.toml`:
<mask> ------- <mask> <mask> Flask will automatically load commands specified in the ``flask.commands`` <mask> `entry point`_. This is useful for extensions that want to add commands when <mask> they are installed. Entry points are specified in :file:`setup.py` :: <mask> <mask> from setuptools import setup...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/cli.rst
.. code-block:: toml
<mask> Flask will automatically load commands specified in the ``flask.commands`` <mask> `entry point`_. This is useful for extensions that want to add commands when <mask> they are installed. Entry points are specified in :file:`setup.py` :: <mask> <mask> from setuptools import setup <mask> <mask> set...
[ "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/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/cli.rst
[project.entry-points."flask.commands"] my-command = "my_extension.commands:cli"
<mask> <mask> .. code-block:: toml <mask> <mask> <mask> .. _entry point: https://packaging.python.org/tutorials/packaging-projects/#entry-points <mask> <mask> Inside :file:`my_extension/commands.py` you can then export a Click <mask> object:: </s> update docs and examples for pyproject setup.py -> pyproje...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/cli.rst
Inside :file:`my_extension/commands.py` you can then export a Click
<mask> <mask> <mask> .. _entry point: https://packaging.python.org/tutorials/packaging-projects/#entry-points <mask> <mask> Inside :file:`flask_my_extension/commands.py` you can then export a Click <mask> object:: <mask> <mask> import click <mask> <mask> @click.command() </s> update docs and exa...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/cli.rst
Define the entry point in :file:`pyproject.toml`:
<mask> @click.group(cls=FlaskGroup, create_app=create_app) <mask> def cli(): <mask> """Management script for the Wiki application.""" <mask> <mask> Define the entry point in :file:`setup.py`:: <mask> <mask> from setuptools import setup <mask> <mask> setup( <mask> name='flask...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/cli.rst
.. code-block:: toml
<mask> """Management script for the Wiki application.""" <mask> <mask> Define the entry point in :file:`setup.py`:: <mask> <mask> from setuptools import setup <mask> <mask> setup( <mask> name='flask-my-extension', <mask> ..., <mask> entry_points={ </s> update docs a...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/cli.rst
[project.scripts] wiki = "wiki:cli"
<mask> Define the entry point in :file:`setup.py`:: <mask> <mask> from setuptools import setup <mask> <mask> setup( <mask> name='flask-my-extension', <mask> ..., <mask> entry_points={ <mask> 'console_scripts': [ <mask> 'wiki=wiki:cli' <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/cli.rst
$ python -m venv .venv $ . .venv/bin/activate
<mask> <mask> .. code-block:: text <mask> <mask> $ cd hello-app <mask> $ python -m venv venv <mask> $ . venv/bin/activate <mask> $ pip install . # install your application <mask> $ pip install eventlet <mask> <mask> <mask> Running </s> update docs and examples for pyproject setup.p...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/deploying/eventlet.rst
$ python -m venv .venv $ . .venv/bin/activate
<mask> <mask> .. code-block:: text <mask> <mask> $ cd hello-app <mask> $ python -m venv venv <mask> $ . venv/bin/activate <mask> $ pip install . # install your application <mask> $ pip install gevent <mask> <mask> <mask> Running </s> update docs and examples for pyproject setup.py ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/deploying/gevent.rst
$ python -m venv .venv $ . .venv/bin/activate
<mask> <mask> .. code-block:: text <mask> <mask> $ cd hello-app <mask> $ python -m venv venv <mask> $ . venv/bin/activate <mask> $ pip install . # install your application <mask> $ pip install gunicorn <mask> <mask> <mask> Running </s> update docs and examples for pyproject setup.p...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/deploying/gunicorn.rst
$ python -m venv .venv $ . .venv/bin/activate
<mask> <mask> .. code-block:: text <mask> <mask> $ cd hello-app <mask> $ python -m venv venv <mask> $ . venv/bin/activate <mask> $ pip install . # install your application <mask> $ pip install mod_wsgi <mask> <mask> <mask> Running </s> update docs and examples for pyproject setup.p...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/deploying/mod_wsgi.rst
$ sudo /home/hello/.venv/bin/mod_wsgi-express start-server \
<mask> mod_wsgi to drop to that user after starting. <mask> <mask> .. code-block:: text <mask> <mask> $ sudo /home/hello/venv/bin/mod_wsgi-express start-server \ <mask> /home/hello/wsgi.py \ <mask> --user hello --group hello --port 80 --processes 4 </s> update docs and examples for pyproje...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/deploying/mod_wsgi.rst
$ python -m venv .venv $ . .venv/bin/activate
<mask> <mask> .. code-block:: text <mask> <mask> $ cd hello-app <mask> $ python -m venv venv <mask> $ . venv/bin/activate <mask> $ pip install . # install your application <mask> $ pip install pyuwsgi <mask> <mask> If you have a compiler available, you can install the ``uwsgi`` package...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/deploying/uwsgi.rst
$ python -m venv .venv $ . .venv/bin/activate
<mask> <mask> .. code-block:: text <mask> <mask> $ cd hello-app <mask> $ python -m venv venv <mask> $ . venv/bin/activate <mask> $ pip install . # install your application <mask> $ pip install waitress <mask> <mask> <mask> Running </s> update docs and examples for pyproject setup.p...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/deploying/waitress.rst
Create a project folder and a :file:`.venv` folder within:
<mask> <mask> Create an environment <mask> ~~~~~~~~~~~~~~~~~~~~~ <mask> <mask> Create a project folder and a :file:`venv` folder within: <mask> <mask> .. tabs:: <mask> <mask> .. group-tab:: macOS/Linux <mask> </s> update docs and examples for pyproject setup.py -> pyproject.toml venv -> .venv </s> r...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/installation.rst
$ python3 -m venv .venv
<mask> .. code-block:: text <mask> <mask> $ mkdir myproject <mask> $ cd myproject <mask> $ python3 -m venv venv <mask> <mask> .. group-tab:: Windows <mask> <mask> .. code-block:: text <mask> </s> update docs and examples for pyproject setup.py -> pyproject.toml ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/installation.rst
> py -3 -m venv .venv
<mask> .. code-block:: text <mask> <mask> > mkdir myproject <mask> > cd myproject <mask> > py -3 -m venv venv <mask> <mask> <mask> .. _install-activate-env: <mask> <mask> Activate the environment </s> update docs and examples for pyproject setup.py -> pyproject.toml venv...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/installation.rst
$ . .venv/bin/activate
<mask> .. group-tab:: macOS/Linux <mask> <mask> .. code-block:: text <mask> <mask> $ . venv/bin/activate <mask> <mask> .. group-tab:: Windows <mask> <mask> .. code-block:: text <mask> </s> update docs and examples for pyproject setup.py -> pyproject.toml venv -> .venv </s> re...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/installation.rst
> .venv\Scripts\activate
<mask> .. group-tab:: Windows <mask> <mask> .. code-block:: text <mask> <mask> > venv\Scripts\activate <mask> <mask> Your shell prompt will change to show the name of the activated <mask> environment. <mask> <mask> </s> update docs and examples for pyproject setup.py -> pyproject.toml...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/installation.rst
a big problem, just add a new file called :file:`pyproject.toml` next to the inner :file:`yourapplication` folder with the following contents:
<mask> <mask> But how do you run your application now? The naive ``python <mask> yourapplication/__init__.py`` will not work. Let's just say that Python <mask> does not want modules in packages to be the startup file. But that is not <mask> a big problem, just add a new file called :file:`setup.py` next to the...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/patterns/packages.rst
.. code-block:: toml
<mask> does not want modules in packages to be the startup file. But that is not <mask> a big problem, just add a new file called :file:`setup.py` next to the inner <mask> :file:`yourapplication` folder with the following contents:: <mask> <mask> from setuptools import setup <mask> <mask> setup( <mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/patterns/packages.rst
[project] name = "yourapplication" dependencies = [ "flask", ] [build-system] requires = ["setuptools"] build-backend = "setuptools.build_meta"
<mask> :file:`yourapplication` folder with the following contents:: <mask> <mask> from setuptools import setup <mask> <mask> setup( <mask> name='yourapplication', <mask> packages=['yourapplication'], <mask> include_package_data=True, <mask> install_requires=[ <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/patterns/packages.rst
pyproject.toml
<mask> <mask> You should then end up with something like that:: <mask> <mask> /yourapplication <mask> setup.py <mask> /yourapplication <mask> __init__.py <mask> views.py <mask> /static <mask> style.css </s> update docs and examples for...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/patterns/packages.rst
When you want to deploy your application elsewhere, you build a *wheel* (``.whl``) file. Install and use the ``build`` tool to do this.
<mask> <mask> Build and Install <mask> ----------------- <mask> <mask> When you want to deploy your application elsewhere, you build a <mask> distribution file. The current standard for Python distribution is the <mask> *wheel* format, with the ``.whl`` extension. Make sure the wheel library <mask> is install...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/deploy.rst
$ pip install build $ python -m build --wheel
<mask> is installed first: <mask> <mask> .. code-block:: none <mask> <mask> $ pip install wheel <mask> <mask> Running ``setup.py`` with Python gives you a command line tool to issue <mask> build-related commands. The ``bdist_wheel`` command will build a wheel <mask> distribution file. <mask> <mask> ....
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/deploy.rst
``.venv/var/flaskr-instance`` instead.
<mask> $ flask --app flaskr init-db <mask> <mask> When Flask detects that it's installed (not in editable mode), it uses <mask> a different directory for the instance folder. You can find it at <mask> ``venv/var/flaskr-instance`` instead. <mask> <mask> <mask> Configure the Secret Key <mask> --------...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/deploy.rst
:caption: ``.venv/var/flaskr-instance/config.py``
<mask> Create the ``config.py`` file in the instance folder, which the factory <mask> will read from if it exists. Copy the generated value into it. <mask> <mask> .. code-block:: python <mask> :caption: ``venv/var/flaskr-instance/config.py`` <mask> <mask> SECRET_KEY = '192b9bdd22ab9ed4d12e236c78afcb9a3...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/deploy.rst
Making your project installable means that you can build a *wheel* file and install that in another environment, just like you installed Flask in your project's environment. This makes deploying your project the same as installing any other library, so you're using all the standard Python tools to manage everything.
<mask> Make the Project Installable <mask> ============================ <mask> <mask> Making your project installable means that you can build a <mask> *distribution* file and install that in another environment, just like <mask> you installed Flask in your project's environment. This makes deploying <mask> you...
[ "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/install.rst
The ``pyproject.toml`` file describes your project and how to build it.
<mask> <mask> Describe the Project <mask> -------------------- <mask> <mask> The ``setup.py`` file describes your project and the files that belong <mask> to it. <mask> <mask> .. code-block:: python <mask> :caption: ``setup.py`` <mask> <mask> from setuptools import find_packages, setup </s> upda...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/install.rst
.. code-block:: toml :caption: ``pyproject.toml``
<mask> <mask> The ``setup.py`` file describes your project and the files that belong <mask> to it. <mask> <mask> .. code-block:: python <mask> :caption: ``setup.py`` <mask> <mask> from setuptools import find_packages, setup <mask> <mask> setup( <mask> name='flaskr', </s> update docs ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/install.rst
[project] name = "flaskr" version = "1.0.0" dependencies = [ "flask", ]
<mask> <mask> .. code-block:: python <mask> :caption: ``setup.py`` <mask> <mask> from setuptools import find_packages, setup <mask> <mask> setup( <mask> name='flaskr', <mask> version='1.0.0', <mask> packages=find_packages(), </s> update docs and examples for pyproject ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/install.rst
[build-system] requires = ["setuptools"] build-backend = "setuptools.build_meta"
<mask> :caption: ``setup.py`` <mask> <mask> from setuptools import find_packages, setup <mask> <mask> setup( <mask> name='flaskr', <mask> version='1.0.0', <mask> packages=find_packages(), <mask> include_package_data=True, <mask> install_requires=[ <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/install.rst
The setuptools build backend needs another file named ``MANIFEST.in`` to tell it about non-Python files to include.
<mask> ], <mask> ) <mask> <mask> <mask> ``packages`` tells Python what package directories (and the Python files <mask> they contain) to include. ``find_packages()`` finds these directories <mask> automatically so you don't have to type them out. To include other <mask> files, such as the static a...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/install.rst
This tells the build to copy everything in the ``static`` and ``templates`` directories, and the ``schema.sql`` file, but to exclude all bytecode files.
<mask> graft flaskr/static <mask> graft flaskr/templates <mask> global-exclude *.pyc <mask> <mask> This tells Python to copy everything in the ``static`` and ``templates`` <mask> directories, and the ``schema.sql`` file, but to exclude all bytecode <mask> files. <mask> <mask> See the official `Pa...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/install.rst
This tells pip to find ``pyproject.toml`` in the current directory and install the project in *editable* or *development* mode. Editable mode means that as you make changes to your local code, you'll only need to re-install if you change the metadata about the project, such as its dependencies.
<mask> .. code-block:: none <mask> <mask> $ pip install -e . <mask> <mask> This tells pip to find ``setup.py`` in the current directory and install <mask> it in *editable* or *development* mode. Editable mode means that as you <mask> make changes to your local code, you'll only need to re-install if you <...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/install.rst
* ``.venv/``, a Python virtual environment where Flask and other
<mask> <mask> * ``flaskr/``, a Python package containing your application code and <mask> files. <mask> * ``tests/``, a directory containing test modules. <mask> * ``venv/``, a Python virtual environment where Flask and other <mask> dependencies are installed. <mask> * Installation files telling Python how ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/layout.rst
.venv/
<mask> <mask> .. code-block:: none <mask> :caption: ``.gitignore`` <mask> <mask> venv/ <mask> <mask> *.pyc <mask> __pycache__/ <mask> <mask> instance/ </s> update docs and examples for pyproject setup.py -> pyproject.toml venv -> .venv </s> remove venv/ </s> add .venv/ </s> remove v...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/layout.rst
Some extra configuration, which is not required but makes running tests with coverage less verbose, can be added to the project's ``pyproject.toml`` file.
<mask> <mask> Running the Tests <mask> ----------------- <mask> <mask> Some extra configuration, which is not required but makes running <mask> tests with coverage less verbose, can be added to the project's <mask> ``setup.cfg`` file. <mask> <mask> .. code-block:: none <mask> :caption: ``setup.cfg`` <...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/tests.rst
.. code-block:: toml :caption: ``pyproject.toml``
<mask> Some extra configuration, which is not required but makes running <mask> tests with coverage less verbose, can be added to the project's <mask> ``setup.cfg`` file. <mask> <mask> .. code-block:: none <mask> :caption: ``setup.cfg`` <mask> <mask> [tool:pytest] <mask> testpaths = tests <mask>...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/tests.rst
[tool.pytest.ini_options] testpaths = ["tests"]
<mask> <mask> .. code-block:: none <mask> :caption: ``setup.cfg`` <mask> <mask> [tool:pytest] <mask> testpaths = tests <mask> <mask> [coverage:run] <mask> branch = True <mask> source = <mask> flaskr </s> update docs and examples for pyproject setup.py -> pyproject.toml ve...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/tests.rst
[tool.coverage.run] branch = true source = ["flaskr"]
<mask> <mask> [tool:pytest] <mask> testpaths = tests <mask> <mask> [coverage:run] <mask> branch = True <mask> source = <mask> flaskr <mask> <mask> To run the tests, use the ``pytest`` command. It will find and run all <mask> the test functions you've written. <mask> <mask> ....
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/tests.rst
rootdir: /home/user/Projects/flask-tutorial
<mask> $ pytest <mask> <mask> ========================= test session starts ========================== <mask> platform linux -- Python 3.6.4, pytest-3.5.0, py-1.5.3, pluggy-0.6.0 <mask> rootdir: /home/user/Projects/flask-tutorial, inifile: setup.cfg <mask> collected 23 items <mask> <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
docs/tutorial/tests.rst
.venv/
<mask> venv/ <mask> *.pyc <mask> __pycache__/ <mask> instance/ <mask> .cache/ <mask> .pytest_cache/ </s> update docs and examples for pyproject setup.py -> pyproject.toml venv -> .venv </s> remove venv/ </s> add .venv/ </s> remove venv/ </s> add .venv/ </s> remove This tells Python to copy everything ...
[ "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
examples/javascript/.gitignore
$ python3 -m venv .venv $ . .venv/bin/activate
<mask> ------- <mask> <mask> .. code-block:: text <mask> <mask> $ python3 -m venv venv <mask> $ . venv/bin/activate <mask> $ pip install -e . <mask> <mask> <mask> Run <mask> --- </s> update docs and examples for pyproject setup.py -> pyproject.toml venv -> .venv </s> remove $ python -m ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
examples/javascript/README.rst
.venv/
<mask> venv/ <mask> *.pyc <mask> __pycache__/ <mask> instance/ <mask> .cache/ <mask> .pytest_cache/ </s> update docs and examples for pyproject setup.py -> pyproject.toml venv -> .venv
[ "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
examples/tutorial/.gitignore
$ python3 -m venv .venv $ . .venv/bin/activate
<mask> $ cd examples/tutorial <mask> <mask> Create a virtualenv and activate it:: <mask> <mask> $ python3 -m venv venv <mask> $ . venv/bin/activate <mask> <mask> Or on Windows cmd:: <mask> <mask> $ py -3 -m venv venv <mask> $ venv\Scripts\activate.bat </s> update docs and examples fo...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
examples/tutorial/README.rst
$ py -3 -m venv .venv $ .venv\Scripts\activate.bat
<mask> $ . venv/bin/activate <mask> <mask> Or on Windows cmd:: <mask> <mask> $ py -3 -m venv venv <mask> $ venv\Scripts\activate.bat <mask> <mask> Install Flaskr:: <mask> <mask> $ pip install -e . <mask> </s> update docs and examples for pyproject setup.py -> pyproject.toml venv -> .ve...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f13f5b6d672f1ba434f9c8ebe2c1b1dd385962e
examples/tutorial/README.rst
def show_server_banner(env, debug, app_import_path, eager_loading=True):
<mask> <mask> return new_dir is not None # at least one file was located and loaded <mask> <mask> <mask> def show_server_banner(env, debug, app_import_path): <mask> """Show extra startup messages the first time the server is run, <mask> ignoring the reloader. <mask> """ <mask> if os.env...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f5168cb31a34c54c9a751cb386b8615e03fb148
flask/cli.py
message = ' * Serving Flask app "{0}"'.format(app_import_path) if not eager_loading: message += ' (lazy loading)' print(message)
<mask> if os.environ.get('WERKZEUG_RUN_MAIN') == 'true': <mask> return <mask> <mask> if app_import_path is not None: <mask> print(' * Serving Flask app "{0}"'.format(app_import_path)) <mask> <mask> print(' * Environment: {0}'.format(env)) <mask> <mask> if env == 'production':...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f5168cb31a34c54c9a751cb386b8615e03fb148
flask/cli.py
show_server_banner(get_env(), debug, info.app_import_path, eager_loading)
<mask> <mask> if eager_loading is None: <mask> eager_loading = not reload <mask> <mask> show_server_banner(get_env(), debug, info.app_import_path) <mask> app = DispatchingApp(info.load_app, use_eager_loading=eager_loading) <mask> <mask> from werkzeug.serving import run_simple <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8f5168cb31a34c54c9a751cb386b8615e03fb148
flask/cli.py
on `PyPI`_.
<mask> =========================== <mask> <mask> Flask, being a microframework, often requires some repetitive steps to get <mask> a third party library working. Many such extensions are already available <mask> on `PyPI <https://pypi.org/search/?c=Framework+%3A%3A+Flask>`_. <mask> <mask> If you want to create...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/90004a83befdb1d65df8632e48078fd721932590
docs/extensiondev.rst
<mask> exist yet, this guide to extension development will help you get your <mask> extension running in no time and to feel like users would expect your <mask> extension to behave. <mask> <mask> .. _Flask Extension Registry: http://flask.pocoo.org/extensions/ <mask> <mask> Anatomy of an Extension <mask> ----...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/90004a83befdb1d65df8632e48078fd721932590
docs/extensiondev.rst
This documentation only touches the bare minimum for extension development. If you want to learn more, it's a very good idea to check out existing extensions on the `PyPI`_. If you feel lost there is still the `mailinglist`_ and the `IRC channel`_ to get some ideas for nice looking APIs. Especially if you do somethin...
<mask> <mask> Learn from Others <mask> ----------------- <mask> <mask> This documentation only touches the bare minimum for extension <mask> development. If you want to learn more, it's a very good idea to check <mask> out existing extensions on the `Flask Extension Registry`_. If you feel <mask> lost there...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/90004a83befdb1d65df8632e48078fd721932590
docs/extensiondev.rst
new releases. If you want your own extension to be approved you have to follow these guidelines:
<mask> ------------------- <mask> <mask> Flask also has the concept of approved extensions. Approved extensions <mask> are tested as part of Flask itself to ensure extensions do not break on <mask> new releases. These approved extensions are listed on the `Flask <mask> Extension Registry`_ and marked appropria...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/90004a83befdb1d65df8632e48078fd721932590
docs/extensiondev.rst
.. _PyPI: https://pypi.org/search/?c=Framework+%3A%3A+Flask
<mask> <mask> <mask> .. _OAuth extension: https://pythonhosted.org/Flask-OAuth/ <mask> .. _mailinglist: http://flask.pocoo.org/mailinglist/ <mask> .. _IRC channel: http://flask.pocoo.org/community/irc/ <mask> .. _Official Pallets Themes: https://pypi.org/project/Pallets-Sphinx-Themes/ </s> Update outdated exte...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/90004a83befdb1d65df8632e48078fd721932590
docs/extensiondev.rst
Flask extensions are usually named "Flask-Foo" or "Foo-Flask". You can search PyPI for packages tagged with `Framework :: Flask <pypi_>`_.
<mask> <mask> Finding Extensions <mask> ------------------ <mask> <mask> Flask extensions are usually named "Flask-Foo" or "Foo-Flask". Many <mask> extensions are listed in the `Extension Registry`_, which can be updated <mask> by extension developers. You can also search PyPI for packages tagged <mask> with ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/90004a83befdb1d65df8632e48078fd721932590
docs/extensions.rst
While the `PyPI <pypi_>`_ contains many Flask extensions, you may
<mask> <mask> Building Extensions <mask> ------------------- <mask> <mask> While the `Extension Registry`_ contains many Flask extensions, you may <mask> not find an extension that fits your need. If this is the case, you can <mask> create your own. Read :ref:`extension-dev` to develop your own Flask <mask> e...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/90004a83befdb1d65df8632e48078fd721932590
docs/extensions.rst
<mask> create your own. Read :ref:`extension-dev` to develop your own Flask <mask> extension. <mask> <mask> <mask> .. _Extension Registry: http://flask.pocoo.org/extensions/ <mask> .. _pypi: https://pypi.org/search/?c=Framework+%3A%3A+Flask </s> Update outdated extension doc Remove links and descriptions rela...
[ "keep", "keep", "keep", "keep", "replace", "keep" ]
https://github.com/pallets/flask/commit/90004a83befdb1d65df8632e48078fd721932590
docs/extensions.rst
- Error handlers for ``InternalServerError`` or ``500`` will always be passed an instance of ``InternalServerError``. If they are invoked due to an unhandled exception, that original exception is now available as ``e.original_exception`` rather than being passed directly to the handler. The same is tr...
<mask> Unreleased <mask> <mask> - Bump minimum Werkzeug version to >= 0.15. <mask> - Drop support for Python 3.4. <mask> - :meth:`flask.RequestContext.copy` includes the current session <mask> object in the request context copy. This prevents ``session`` <mask> pointing to an out-of-date object. (...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9054f6d6397607647839286ce1db6cb2ef8457fe
CHANGES.rst
"""Handle an exception that did not have an error handler associated with it, or that was raised from an error handler. This always causes a 500 ``InternalServerError``. Always sends the :data:`got_request_exception` signal. If :attr:`propagate_exceptions` is ``True``, such as ...
<mask> reraise(exc_type, exc_value, tb) <mask> return handler(e) <mask> <mask> def handle_exception(self, e): <mask> """Default exception handling that kicks in when an exception <mask> occurs that is not caught. In debug mode the exception will <mask> be re-rais...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9054f6d6397607647839286ce1db6cb2ef8457fe
src/flask/app.py
server_error = InternalServerError() # TODO: pass as param when Werkzeug>=1.0.0 is required # TODO: also remove note about this from docstring and docs server_error.original_exception = e handler = self._find_error_handler(server_error) if handler is not None: ...
<mask> else: <mask> raise e <mask> <mask> self.log_exception((exc_type, exc_value, tb)) <mask> handler = self._find_error_handler(InternalServerError()) <mask> if handler is None: <mask> return InternalServerError() <mask> return self.fina...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9054f6d6397607647839286ce1db6cb2ef8457fe
src/flask/app.py
import pytest
<mask> :license: BSD, see LICENSE for more details. <mask> """ <mask> from werkzeug.exceptions import Forbidden <mask> from werkzeug.exceptions import HTTPException <mask> from werkzeug.exceptions import InternalServerError <mask> from werkzeug.exceptions import NotFound <mask> </s> always pass InternalServerE...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9054f6d6397607647839286ce1db6cb2ef8457fe
tests/test_user_error_handler.py
assert isinstance(e, InternalServerError) original = getattr(e, "original_exception", None) if original is not None: return "wrapped " + type(original).__name__ return "direct"
<mask> return "custom" <mask> <mask> @app.errorhandler(500) <mask> def handle_500(e): <mask> return type(e).__name__ <mask> <mask> @app.route("/custom") <mask> def custom_test(): <mask> raise CustomException() <mask> </s> always pass InternalServerError instance to ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9054f6d6397607647839286ce1db6cb2ef8457fe
tests/test_user_error_handler.py
@app.route("/abort") def do_abort(): flask.abort(500)
<mask> @app.route("/keyerror") <mask> def key_error(): <mask> raise KeyError() <mask> <mask> app.testing = False <mask> assert client.get("/custom").data == b"custom" <mask> assert client.get("/keyerror").data == b"wrapped KeyError" <mask> assert client.get("/abort").data == b"d...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9054f6d6397607647839286ce1db6cb2ef8457fe
tests/test_user_error_handler.py
assert client.get("/keyerror").data == b"wrapped KeyError" assert client.get("/abort").data == b"direct"
<mask> raise KeyError() <mask> <mask> app.testing = False <mask> assert client.get("/custom").data == b"custom" <mask> assert client.get("/keyerror").data == b"KeyError" <mask> <mask> <mask> def test_error_handler_subclass(app): <mask> class ParentException(Exception): <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9054f6d6397607647839286ce1db6cb2ef8457fe
tests/test_user_error_handler.py
DATABASE=os.path.join(app.root_path, 'flaskr.db'),
<mask> app.config.from_object(__name__) <mask> <mask> # Load default config and override config from an environment variable <mask> app.config.update(dict( <mask> DATABASE='/tmp/flaskr.db', <mask> DEBUG=True, <mask> SECRET_KEY='development key', <mask> USERNAME='admi...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9074bc46af69f168e059dc977f90bbeb6d250077
docs/tutorial/setup.rst
.. admonition:: Database Path
<mask> <mask> The :class:`~flask.Config` object works similar to a dictionary so we <mask> can update it with new values. <mask> <mask> .. admonition:: Windows <mask> <mask> If you are on Windows, replace `/tmp/flaskr.db` with a different writeable <mask> path of your choice, in the configuration and...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9074bc46af69f168e059dc977f90bbeb6d250077
docs/tutorial/setup.rst
Operating systems know the concept of a current working directory for each process. Unfortunately you cannot depend on this in web applications because you might have more than one application in the same process. For this reason the ``app.root_path`` attribute can be used to get the path to t...
<mask> can update it with new values. <mask> <mask> .. admonition:: Windows <mask> <mask> If you are on Windows, replace `/tmp/flaskr.db` with a different writeable <mask> path of your choice, in the configuration and for the rest of this <mask> tutorial. <mask> <mask> Usually, it is a good idea...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9074bc46af69f168e059dc977f90bbeb6d250077
docs/tutorial/setup.rst
import os
<mask> :copyright: (c) 2014 by Armin Ronacher. <mask> :license: BSD, see LICENSE for more details. <mask> """ <mask> <mask> from sqlite3 import dbapi2 as sqlite3 <mask> from flask import Flask, request, session, g, redirect, url_for, abort, \ <mask> render_template, flash <mask> </s> Switch away...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9074bc46af69f168e059dc977f90bbeb6d250077
examples/flaskr/flaskr.py
DATABASE=os.path.join(app.root_path, 'flaskr.db'),
<mask> app = Flask(__name__) <mask> <mask> # Load default config and override config from an environment variable <mask> app.config.update(dict( <mask> DATABASE='/tmp/flaskr.db', <mask> DEBUG=True, <mask> SECRET_KEY='development key', <mask> USERNAME='admin', <mask> PASSWORD='default' <ma...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9074bc46af69f168e059dc977f90bbeb6d250077
examples/flaskr/flaskr.py
def run(self, host='127.0.0.1', port=5000, debug=None, **options):
<mask> # easier add new variables in context processors without breaking <mask> # existing views. <mask> context.update(orig_ctx) <mask> <mask> def run(self, host='127.0.0.1', port=5000, **options): <mask> """Runs the application on a local development server. If the <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/907c24e6ffc436971d437b0b9122b840db9466d7
flask/app.py
:param debug: if given, enable or disable debug mode.
<mask> <mask> :param host: the hostname to listen on. set this to ``'0.0.0.0'`` <mask> to have the server available externally as well. <mask> :param port: the port of the webserver <mask> :param options: the options to be forwarded to the underlying <mask> ...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/907c24e6ffc436971d437b0b9122b840db9466d7
flask/app.py
if debug is not None: self.debug = bool(debug)
<mask> :func:`werkzeug.serving.run_simple` for more <mask> information. <mask> """ <mask> from werkzeug.serving import run_simple <mask> if 'debug' in options: <mask> self.debug = options.pop('debug') <mask> options.setde...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/907c24e6ffc436971d437b0b9122b840db9466d7
flask/app.py
from .globals import _cv_request
<mask> from .ctx import _AppCtxGlobals <mask> from .ctx import AppContext <mask> from .ctx import RequestContext <mask> from .globals import _cv_app <mask> from .globals import _cv_req <mask> from .globals import g <mask> from .globals import request <mask> from .globals import request_ctx <mask> from .globals...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/app.py
req_ctx = _cv_request.get(None)
<mask> <mask> .. versionadded:: 2.2 <mask> Moved from ``flask.url_for``, which calls this method. <mask> """ <mask> req_ctx = _cv_req.get(None) <mask> <mask> if req_ctx is not None: <mask> url_adapter = req_ctx.url_adapter <mask> blueprint_n...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/app.py
environ["werkzeug.debug.preserve_context"](_cv_request.get())
<mask> return response(environ, start_response) <mask> finally: <mask> if "werkzeug.debug.preserve_context" in environ: <mask> environ["werkzeug.debug.preserve_context"](_cv_app.get()) <mask> environ["werkzeug.debug.preserve_context"](_cv_req.get()) ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/app.py
from .globals import _cv_request
<mask> from werkzeug.exceptions import HTTPException <mask> <mask> from . import typing as ft <mask> from .globals import _cv_app <mask> from .globals import _cv_req <mask> from .signals import appcontext_popped <mask> from .signals import appcontext_pushed <mask> <mask> if t.TYPE_CHECKING: # pragma: no cov...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/ctx.py
ctx = _cv_request.get(None)
<mask> some headers without converting the return value into a response object. <mask> <mask> .. versionadded:: 0.9 <mask> """ <mask> ctx = _cv_req.get(None) <mask> <mask> if ctx is None: <mask> raise RuntimeError( <mask> "'after_this_request' can only be used when a r...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/ctx.py
ctx = _cv_request.get(None)
<mask> return 'Regular response' <mask> <mask> .. versionadded:: 0.10 <mask> """ <mask> ctx = _cv_req.get(None) <mask> <mask> if ctx is None: <mask> raise RuntimeError( <mask> "'copy_current_request_context' can only be used when a" <mask> " reques...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/ctx.py
return _cv_request.get(None) is not None
<mask> :data:`current_app` object instead. <mask> <mask> .. versionadded:: 0.9 <mask> """ <mask> return _cv_req.get(None) is not None <mask> <mask> <mask> class AppContext: <mask> """The app context contains application-specific information. An app <mask> context is created and push...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/ctx.py
self._cv_tokens.append((_cv_request.set(self), app_ctx))
<mask> app_ctx.push() <mask> else: <mask> app_ctx = None <mask> <mask> self._cv_tokens.append((_cv_req.set(self), app_ctx)) <mask> <mask> # Open the session at the moment that the request context is available. <mask> # This allows a custom open_session m...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/ctx.py
ctx = _cv_request.get()
<mask> request_close = getattr(self.request, "close", None) <mask> if request_close is not None: <mask> request_close() <mask> finally: <mask> ctx = _cv_req.get() <mask> token, app_ctx = self._cv_tokens.pop() <mask> _...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/ctx.py
_cv_request.reset(token)
<mask> request_close() <mask> finally: <mask> ctx = _cv_req.get() <mask> token, app_ctx = self._cv_tokens.pop() <mask> _cv_req.reset(token) <mask> <mask> # get rid of circular dependencies at the end of the request <mask> #...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/ctx.py
_cv_request: ContextVar["RequestContext"] = ContextVar("flask.request_ctx") __request_ctx_stack = _FakeStack("request", _cv_request)
<mask> This typically means that you attempted to use functionality that needed <mask> an active HTTP request. Consult the documentation on testing for <mask> information about how to avoid this problem.\ <mask> """ <mask> _cv_req: ContextVar["RequestContext"] = ContextVar("flask.request_ctx") <mask> __request_ct...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/globals.py
_cv_request, unbound_message=_no_req_msg
<mask> """ <mask> _cv_req: ContextVar["RequestContext"] = ContextVar("flask.request_ctx") <mask> __request_ctx_stack = _FakeStack("request", _cv_req) <mask> request_ctx: "RequestContext" = LocalProxy( # type: ignore[assignment] <mask> _cv_req, unbound_message=_no_req_msg <mask> ) <mask> request: "Request" =...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/globals.py
_cv_request, "request", unbound_message=_no_req_msg
<mask> request_ctx: "RequestContext" = LocalProxy( # type: ignore[assignment] <mask> _cv_req, unbound_message=_no_req_msg <mask> ) <mask> request: "Request" = LocalProxy( # type: ignore[assignment] <mask> _cv_req, "request", unbound_message=_no_req_msg <mask> ) <mask> session: "SessionMixin" = LocalPro...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/globals.py
_cv_request, "session", unbound_message=_no_req_msg
<mask> request: "Request" = LocalProxy( # type: ignore[assignment] <mask> _cv_req, "request", unbound_message=_no_req_msg <mask> ) <mask> session: "SessionMixin" = LocalProxy( # type: ignore[assignment] <mask> _cv_req, "session", unbound_message=_no_req_msg <mask> ) <mask> <mask> <mask> def __getat...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/globals.py
from .globals import _cv_request
<mask> import werkzeug.utils <mask> from werkzeug.exceptions import abort as _wz_abort <mask> from werkzeug.utils import redirect as _wz_redirect <mask> <mask> from .globals import _cv_req <mask> from .globals import current_app <mask> from .globals import request <mask> from .globals import request_ctx <mask...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/helpers.py
ctx = _cv_request.get(None)
<mask> <mask> return update_wrapper(decorator, generator_or_function) # type: ignore <mask> <mask> def generator() -> t.Generator: <mask> ctx = _cv_req.get(None) <mask> if ctx is None: <mask> raise RuntimeError( <mask> "'stream_with_context' can only be...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/helpers.py
from .globals import _cv_request
<mask> from jinja2 import Template <mask> from jinja2 import TemplateNotFound <mask> <mask> from .globals import _cv_app <mask> from .globals import _cv_req <mask> from .globals import current_app <mask> from .globals import request <mask> from .helpers import stream_with_context <mask> from .signals import b...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/templating.py
reqctx = _cv_request.get(None)
<mask> """Default template context processor. Injects `request`, <mask> `session` and `g`. <mask> """ <mask> appctx = _cv_app.get(None) <mask> reqctx = _cv_req.get(None) <mask> rv: t.Dict[str, t.Any] = {} <mask> if appctx is not None: <mask> rv["g"] = appctx.g <mask> if...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/templating.py
from .globals import _cv_request
<mask> from werkzeug.urls import url_parse <mask> from werkzeug.wrappers import Request as BaseRequest <mask> <mask> from .cli import ScriptInfo <mask> from .globals import _cv_req <mask> from .json import dumps as json_dumps <mask> from .sessions import SessionMixin <mask> <mask> if t.TYPE_CHECKING: # prag...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/testing.py
outer_reqctx = _cv_request.get(None)
<mask> ) <mask> app = self.application <mask> environ_overrides = kwargs.setdefault("environ_overrides", {}) <mask> self.cookie_jar.inject_wsgi(environ_overrides) <mask> outer_reqctx = _cv_req.get(None) <mask> with app.test_request_context(*args, **kwargs) as c:...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/testing.py
token = _cv_request.set(outer_reqctx) # type: ignore[arg-type]
<mask> # (or None) on top of this and popping it we get exactly that <mask> # behavior. It's important to not use the push and pop <mask> # methods of the actual request context object since that would <mask> # mean that cleanup handlers are called <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/91044c4d769efa7f20455e1b70457a7da95c26d8
src/flask/testing.py
This is all that is necessary to integrate Celery with Flask: .. code-block:: python
<mask> Celery without any reconfiguration with Flask, it becomes a bit nicer by <mask> subclassing tasks and adding support for Flask's application contexts and <mask> hooking it up with the Flask configuration. <mask> <mask> This is all that is necessary to properly integrate Celery with Flask:: <mask> <mask>...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9252be9c9ebe46dd6415b24999a869ed87eace57
docs/patterns/celery.rst
celery = Celery(app.import_name) celery.conf.update(app.config["CELERY_CONFIG"])
<mask> <mask> from celery import Celery <mask> <mask> def make_celery(app): <mask> celery = Celery( <mask> app.import_name, <mask> backend=app.config['CELERY_RESULT_BACKEND'], <mask> broker=app.config['CELERY_BROKER_URL'] <mask> ) <mask> ce...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9252be9c9ebe46dd6415b24999a869ed87eace57
docs/patterns/celery.rst
.. note:: Celery 5.x deprecated uppercase configuration keys, and 6.x will remove them. See their official `migration guide`_. .. _migration guide: https://docs.celeryproject.org/en/stable/userguide/configuration.html#conf-old-settings-map.
<mask> task execution in an application context. <mask> <mask> An example task <mask> --------------- <mask> <mask> Let's write a task that adds two numbers together and returns the result. We <mask> configure Celery's broker and backend to use Redis, create a ``celery`` <mask> application using the factory f...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9252be9c9ebe46dd6415b24999a869ed87eace57
docs/patterns/celery.rst
flask_app.config.update(CELERY_CONFIG={ 'broker_url': 'redis://localhost:6379', 'result_backend': 'redis://localhost:6379', })
<mask> <mask> from flask import Flask <mask> <mask> flask_app = Flask(__name__) <mask> flask_app.config.update( <mask> CELERY_BROKER_URL='redis://localhost:6379', <mask> CELERY_RESULT_BACKEND='redis://localhost:6379' <mask> ) <mask> celery = make_celery(flask_app) <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9252be9c9ebe46dd6415b24999a869ed87eace57
docs/patterns/celery.rst