First implementation of bindings
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import logging
|
||||
from importlib.resources import files
|
||||
from pathlib import Path
|
||||
from typing import Optional, Any
|
||||
@@ -8,6 +9,9 @@ from starlette.responses import Response
|
||||
|
||||
from myfasthtml.auth.routes import setup_auth_routes
|
||||
from myfasthtml.auth.utils import create_auth_beforeware
|
||||
from myfasthtml.core.utils import utils_app
|
||||
|
||||
logger = logging.getLogger("MyFastHtml")
|
||||
|
||||
|
||||
def get_asset_path(filename):
|
||||
@@ -25,7 +29,7 @@ def get_asset_content(filename):
|
||||
return get_asset_path(filename).read_text()
|
||||
|
||||
|
||||
def create_app(daisyui: Optional[bool] = False,
|
||||
def create_app(daisyui: Optional[bool] = True,
|
||||
protect_routes: Optional[bool] = True,
|
||||
mount_auth_app: Optional[bool] = False,
|
||||
**kwargs) -> Any:
|
||||
@@ -50,10 +54,10 @@ def create_app(daisyui: Optional[bool] = False,
|
||||
:return: A tuple containing the FastHtml application instance and the associated router.
|
||||
:rtype: Any
|
||||
"""
|
||||
hdrs = []
|
||||
hdrs = [Link(href="/myfasthtml/myfasthtml.css", rel="stylesheet", type="text/css")]
|
||||
|
||||
if daisyui:
|
||||
hdrs = [
|
||||
hdrs += [
|
||||
Link(href="/myfasthtml/daisyui-5.css", rel="stylesheet", type="text/css"),
|
||||
Link(href="/myfasthtml/daisyui-5-themes.css", rel="stylesheet", type="text/css"),
|
||||
Script(src="/myfasthtml/tailwindcss-browser@4.js"),
|
||||
@@ -84,6 +88,9 @@ def create_app(daisyui: Optional[bool] = False,
|
||||
# and put it back after the myfasthtml static files routes
|
||||
app.routes.append(static_route_exts_get)
|
||||
|
||||
# route the commands and the bindings
|
||||
app.mount("/myfasthtml", utils_app)
|
||||
|
||||
if mount_auth_app:
|
||||
# Setup authentication routes
|
||||
setup_auth_routes(app, rt)
|
||||
|
||||
Reference in New Issue
Block a user