|
|
|
|
@@ -7,6 +7,7 @@ from fasthtml.components import Link, Script
|
|
|
|
|
from starlette.responses import Response
|
|
|
|
|
|
|
|
|
|
from myfasthtml.auth.routes import setup_auth_routes
|
|
|
|
|
from myfasthtml.auth.utils import create_auth_beforeware
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_asset_path(filename):
|
|
|
|
|
@@ -24,7 +25,10 @@ def get_asset_content(filename):
|
|
|
|
|
return get_asset_path(filename).read_text()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_app(daisyui: Optional[bool] = False, mount_auth_app: Optional[bool] = False, **kwargs) -> Any:
|
|
|
|
|
def create_app(daisyui: Optional[bool] = False,
|
|
|
|
|
protect_routes: Optional[bool] = True,
|
|
|
|
|
mount_auth_app: Optional[bool] = False,
|
|
|
|
|
**kwargs) -> Any:
|
|
|
|
|
"""
|
|
|
|
|
Creates and configures a FastHtml application with optional support for daisyUI themes and
|
|
|
|
|
authentication routes.
|
|
|
|
|
@@ -32,6 +36,10 @@ def create_app(daisyui: Optional[bool] = False, mount_auth_app: Optional[bool] =
|
|
|
|
|
:param daisyui: Flag to enable or disable inclusion of daisyUI-related assets for styling.
|
|
|
|
|
Defaults to False.
|
|
|
|
|
:type daisyui: Optional[bool]
|
|
|
|
|
|
|
|
|
|
:param protect_routes: Flag to enable or disable routes protection based on authentication.
|
|
|
|
|
Defaults to True.
|
|
|
|
|
:type protect_routes: Optional[bool]
|
|
|
|
|
|
|
|
|
|
:param mount_auth_app: Flag to enable or disable mounting of authentication routes.
|
|
|
|
|
Defaults to False.
|
|
|
|
|
@@ -51,7 +59,8 @@ def create_app(daisyui: Optional[bool] = False, mount_auth_app: Optional[bool] =
|
|
|
|
|
Script(src="/myfasthtml/tailwindcss-browser@4.js"),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
app, rt = fasthtml.fastapp.fast_app(hdrs=tuple(hdrs), **kwargs)
|
|
|
|
|
beforeware = create_auth_beforeware() if protect_routes else None
|
|
|
|
|
app, rt = fasthtml.fastapp.fast_app(before=beforeware, hdrs=tuple(hdrs), **kwargs)
|
|
|
|
|
|
|
|
|
|
# remove the global static files routes
|
|
|
|
|
static_route_exts_get = app.routes.pop(0)
|
|
|
|
|
|