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