forked from orbit-oss/flask
Merge pull request #3678 from jab/1.1.x-pathlib-static-folder
Cherry-pick 7ba35c4 from master (support pathlib.Path for static_folder)
This commit is contained in:
commit
b82c2e611a
3 changed files with 22 additions and 1 deletions
11
CHANGES.rst
11
CHANGES.rst
|
|
@ -1,5 +1,16 @@
|
||||||
.. currentmodule:: flask
|
.. currentmodule:: flask
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Version 1.1.x
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Not yet released.
|
||||||
|
|
||||||
|
- Officially support passing a :class:`pathlib.Path` for
|
||||||
|
``static_folder`` which stopped working in 1.1.2. :pr:`3579`
|
||||||
|
|
||||||
|
|
||||||
Version 1.1.2
|
Version 1.1.2
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1001,7 +1001,7 @@ class _PackageBoundObject(object):
|
||||||
@static_folder.setter
|
@static_folder.setter
|
||||||
def static_folder(self, value):
|
def static_folder(self, value):
|
||||||
if value is not None:
|
if value is not None:
|
||||||
value = value.rstrip("/\\")
|
value = os.fspath(value).rstrip(r"\/")
|
||||||
self._static_folder = value
|
self._static_folder = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
||||||
|
|
@ -1425,6 +1425,16 @@ def test_static_url_empty_path_default(app):
|
||||||
rv.close()
|
rv.close()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires Python >= 3.6")
|
||||||
|
def test_static_folder_with_pathlib_path(app):
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
app = flask.Flask(__name__, static_folder=Path("static"))
|
||||||
|
rv = app.test_client().open("/static/index.html", method="GET")
|
||||||
|
assert rv.status_code == 200
|
||||||
|
rv.close()
|
||||||
|
|
||||||
|
|
||||||
def test_static_folder_with_ending_slash():
|
def test_static_folder_with_ending_slash():
|
||||||
app = flask.Flask(__name__, static_folder="static/")
|
app = flask.Flask(__name__, static_folder="static/")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue