forked from orbit-oss/flask
Merge pull request #4152 from Yourun-proger/fix
`static_folder` can be a `pathlib.Path` object
This commit is contained in:
commit
06cf349bb8
4 changed files with 8 additions and 5 deletions
|
|
@ -13,6 +13,8 @@ Unreleased
|
|||
- Support View and MethodView instances with async handlers. :issue:`4112`
|
||||
- Enhance typing of ``app.errorhandler`` decorator. :issue:`4095`
|
||||
- Fix registering a blueprint twice with differing names. :issue:`4124`
|
||||
- Fix the type of ``static_folder`` to accept ``pathlib.Path``.
|
||||
:issue:`4150`
|
||||
|
||||
|
||||
Version 2.0.1
|
||||
|
|
|
|||
|
|
@ -389,7 +389,7 @@ class Flask(Scaffold):
|
|||
self,
|
||||
import_name: str,
|
||||
static_url_path: t.Optional[str] = None,
|
||||
static_folder: t.Optional[str] = "static",
|
||||
static_folder: t.Optional[t.Union[str, os.PathLike]] = "static",
|
||||
static_host: t.Optional[str] = None,
|
||||
host_matching: bool = False,
|
||||
subdomain_matching: bool = False,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
import typing as t
|
||||
from collections import defaultdict
|
||||
from functools import update_wrapper
|
||||
|
|
@ -175,7 +176,7 @@ class Blueprint(Scaffold):
|
|||
self,
|
||||
name: str,
|
||||
import_name: str,
|
||||
static_folder: t.Optional[str] = None,
|
||||
static_folder: t.Optional[t.Union[str, os.PathLike]] = None,
|
||||
static_url_path: t.Optional[str] = None,
|
||||
template_folder: t.Optional[str] = None,
|
||||
url_prefix: t.Optional[str] = None,
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class Scaffold:
|
|||
def __init__(
|
||||
self,
|
||||
import_name: str,
|
||||
static_folder: t.Optional[str] = None,
|
||||
static_folder: t.Optional[t.Union[str, os.PathLike]] = None,
|
||||
static_url_path: t.Optional[str] = None,
|
||||
template_folder: t.Optional[str] = None,
|
||||
root_path: t.Optional[str] = None,
|
||||
|
|
@ -101,7 +101,7 @@ class Scaffold:
|
|||
#: to. Do not change this once it is set by the constructor.
|
||||
self.import_name = import_name
|
||||
|
||||
self.static_folder = static_folder
|
||||
self.static_folder = static_folder # type: ignore
|
||||
self.static_url_path = static_url_path
|
||||
|
||||
#: The path to the templates folder, relative to
|
||||
|
|
@ -257,7 +257,7 @@ class Scaffold:
|
|||
return None
|
||||
|
||||
@static_folder.setter
|
||||
def static_folder(self, value: t.Optional[str]) -> None:
|
||||
def static_folder(self, value: t.Optional[t.Union[str, os.PathLike]]) -> None:
|
||||
if value is not None:
|
||||
value = os.fspath(value).rstrip(r"\/")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue