find custom static folder
This commit is contained in:
parent
dd9c21b431
commit
daf21d0afd
@ -34,10 +34,15 @@ class MyQuartApp(quart_trio.QuartTrio):
|
|||||||
def __init__(self, import_name: str, **kwargs) -> None:
|
def __init__(self, import_name: str, **kwargs) -> None:
|
||||||
self.my_config = capport.config.Config.load_default_once()
|
self.my_config = capport.config.Config.load_default_once()
|
||||||
kwargs.setdefault('template_folder', os.path.join(os.path.dirname(__file__), 'templates'))
|
kwargs.setdefault('template_folder', os.path.join(os.path.dirname(__file__), 'templates'))
|
||||||
kwargs.setdefault('static_folder', os.path.join(os.path.dirname(__file__), 'static'))
|
|
||||||
cust_templ = os.path.join('custom', 'templates')
|
cust_templ = os.path.join('custom', 'templates')
|
||||||
if os.path.exists(cust_templ):
|
if os.path.exists(cust_templ):
|
||||||
self.custom_loader = jinja2.FileSystemLoader(os.fspath(cust_templ))
|
self.custom_loader = jinja2.FileSystemLoader(os.fspath(cust_templ))
|
||||||
|
cust_static = os.path.abspath(os.path.join('custom', 'static'))
|
||||||
|
if os.path.exists(cust_static):
|
||||||
|
static_folder = cust_static
|
||||||
|
else:
|
||||||
|
static_folder = os.path.join(os.path.dirname(__file__), 'static')
|
||||||
|
kwargs.setdefault('static_folder', static_folder)
|
||||||
super().__init__(import_name, **kwargs)
|
super().__init__(import_name, **kwargs)
|
||||||
self.debug = self.my_config.debug
|
self.debug = self.my_config.debug
|
||||||
self.secret_key = self.my_config.cookie_secret
|
self.secret_key = self.my_config.cookie_secret
|
||||||
|
Loading…
Reference in New Issue
Block a user