from contextlib import asynccontextmanager import flet.fastapi as flet_fastapi import logging from fastapi import FastAPI from pathlib import Path from flet_app import main from js_execution import mount_flet_app from flet_extensions import extend_flet_page # Set up basic logging configuration logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') logger = logging.getLogger(__name__) @asynccontextmanager async def lifespan(app: FastAPI): await flet_fastapi.app_manager.start() yield await flet_fastapi.app_manager.shutdown() app = FastAPI(lifespan=lifespan) # Extend the Flet Page class extend_flet_page() current_dir = Path(__file__).parent.resolve() assets_path = current_dir / "assets" # Use the constructed assets path in the flet_fastapi.app call flet_app = flet_fastapi.app(main, assets_dir=str(assets_path)) mount_flet_app(app, "/", flet_app)