Skip to content
Myr

Merge pull request #4019 from greyli/re-add-filename

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Re-add filename parameter for send_from_directory

authored by David Lord · committed by GitHub · parents 80d9519, fc82dd5 · Browse files · 2 files+19 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+19 added−1 removed

  • other:+19 added−1 removed

2 files+19 added−1 removed

modified:src/flask/helpers.py+15 added-1 removed
640 unmodified lines
641642 return path643644645def send_from_directory(directory: str, path: str, **kwargs: t.Any) -> "Response":645def send_from_directory(646 directory: str, path: str, filename: t.Optional[str] = None, **kwargs: t.Any647) -> "Response":648 """Send a file from within a directory using :func:`send_file`.649650 .. code-block:: python651
15 unmodified lines
667 :param path: The path to the file to send, relative to668 ``directory``.669 :param kwargs: Arguments to pass to :func:`send_file`.670671 .. versionchanged:: 2.0672 ``path`` replaces the ``filename`` parameter.673674 .. versionadded:: 2.0675 Moved the implementation to Werkzeug. This is now a wrapper to676 pass some Flask-specific arguments.677678 .. versionadded:: 0.5679 """680 if filename is not None:681 warnings.warn(682 "The 'filename' parameter has been renamed to 'path'. The"683 " old name will be removed in Flask 2.1.",684 DeprecationWarning,685 stacklevel=2,686 )687 path = filename688689 return werkzeug.utils.send_from_directory( # type: ignore690 directory, path, **_prepare_send_file_kwargs(**kwargs)691 )692
123 unmodified lines
modified:CHANGES.rst+4 added
3 unmodified lines
4-------------56Unreleased78- Re-add the ``filename`` parameter in ``send_from_directory``. The9 ``filename`` parameter has been renamed to ``path``, the old name10 is deprecated. :pr:`4019`111213Version 2.0.014-------------1516Released 2021-05-11
1094 unmodified lines