Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ Unreleased
load command entry points. :issue:`4419`
- Overriding ``FlaskClient.open`` will not cause an error on redirect.
:issue:`3396`
- Add an ``--exclude-patterns`` option to the ``flask run`` CLI
command to specify patterns that will be ignored by the reloader.
:issue:`4188`


Version 2.0.3
Expand Down
9 changes: 9 additions & 0 deletions docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,15 @@ separated with ``:``, or ``;`` on Windows.
* Detected change in '/path/to/file1', reloading


Ignore files with the Reloader
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The reloader can also ignore files using :mod:`fnmatch` patterns with
the ``--exclude-patterns`` option, or the ``FLASK_RUN_EXCLUDE_PATTERNS``
environment variable. Multiple patterns are separated with ``:``, or
``;`` on Windows.


Debug Mode
----------

Expand Down
22 changes: 21 additions & 1 deletion src/flask/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,9 +796,28 @@ def convert(self, value, param, ctx):
f" are separated by {os.path.pathsep!r}."
),
)
@click.option(
"--exclude-patterns",
default=None,
type=SeparatedPathType(),
help=(
"Files matching these fnmatch patterns will not trigger a reload"
" on change. Multiple patterns are separated by"
f" {os.path.pathsep!r}."
),
)
@pass_script_info
def run_command(
info, host, port, reload, debugger, eager_loading, with_threads, cert, extra_files
info,
host,
port,
reload,
debugger,
eager_loading,
with_threads,
cert,
extra_files,
exclude_patterns,
):
"""Run a local development server.

Expand Down Expand Up @@ -830,6 +849,7 @@ def run_command(
threaded=with_threads,
ssl_context=cert,
extra_files=extra_files,
exclude_patterns=exclude_patterns,
)


Expand Down