allow setting frontend path

This commit is contained in:
Izalia Mae 2022-04-22 22:44:16 -04:00
parent a376236b17
commit 9aabe9567e
2 changed files with 6 additions and 7 deletions

View file

@ -17,7 +17,6 @@ from .response import ServerResponse
#from .router import Router
from .view import Static, Manifest, Robots, Style
from .. import __file__ as module_root
from ..exceptions import MethodNotHandledException, NoBlueprintForPath
from ..utils import AsyncTransport
from ..template import Template
@ -28,9 +27,6 @@ except ImportError:
Database = NotImplementedError('Failed to import SQL database class')
frontend = Path(module_root).join('../frontend').resolve()
class ApplicationBase:
def __init__(self, appname='default', views=[], middleware=[], dbtype=None, dbargs={}, dbclass=Database, **kwargs):
self.ctx = DotDict()
@ -217,11 +213,11 @@ class Application(ApplicationBase):
self.template.add_env('cfg', self.cfg)
self.template.add_env('len', len)
self.template.add_search_path(frontend)
self.template.add_search_path(self.cfg.frontend_path)
self.add_view(Manifest)
#self.add_view(Robots)
self.add_view(Style)
self.add_static('/framework/static/', frontend.join('static'))
self.add_static('/framework/static/', self.cfg.frontend_path.join('static'))
def __repr__(self):

View file

@ -1,11 +1,13 @@
from izzylib import (
BaseConfig,
LowerDotDict
LowerDotDict,
Path
)
from .request import ServerRequest
from .response import ServerResponse
from .. import __file__ as module_root
from .. import __version__
from ..client import Client
@ -29,6 +31,7 @@ class Config(BaseConfig):
proto = 'http',
access_log = True,
timeout = 60,
frontend_path = Path(module_root).join('../frontend').resolve(),
default_headers = LowerDotDict(),
request_class = ServerRequest,
response_class = ServerResponse,