Skip to content
Myr

Merge pull request #3579 from jab/pathlib-for-static_folder

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

Officially support using pathlib.Path for static_folder.

authored by Joshua Bronson · committed by GitHub · parents b82cca7, 7ba35c4 · Browse files · 3 files+20 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

3 files+20 added−1 removed

  • tests:+10 added−0 removed
  • other:+10 added−1 removed

3 files+20 added−1 removed

modified:src/flask/helpers.py+1 added-1 removed
978 unmodified lines
979980 @static_folder.setter981 def static_folder(self, value):982 if value is not None:983 value = value.rstrip("/\\")983 value = os.fspath(value).rstrip(r"\/")984 self._static_folder = value985986 @property987 def static_url_path(self):
137 unmodified lines
modified:tests/test_basic.py+10 added
1404 unmodified lines
1405 assert rv.status_code == 2001406 rv.close()140714081409@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires Python >= 3.6")1410def test_static_folder_with_pathlib_path(app):1411 from pathlib import Path14121413 app = flask.Flask(__name__, static_folder=Path("static"))1414 rv = app.test_client().open("/static/index.html", method="GET")1415 assert rv.status_code == 2001416 rv.close()141714181419def test_static_folder_with_ending_slash():1420 app = flask.Flask(__name__, static_folder="static/")14211422 @app.route("/<path:path>")
547 unmodified lines
modified:CHANGES.rst+9 added
27 unmodified lines
28- When specifying a factory function with ``FLASK_APP``, keyword29 argument can be passed. :issue:`3553`303132Version 1.1.x33-------------3435Not yet released.3637- Officially support passing a :class:`pathlib.Path` for38 ``static_folder`` which stopped working in 1.1.2. :pr:`3579`394041Version 1.1.242-------------4344Released 2020-04-03
1009 unmodified lines