File size: 911 Bytes
b6110c3
 
8ea6cba
0b2be8e
c992804
0b2be8e
 
 
2a87a37
8ea6cba
 
60f2a54
8ea6cba
c7aa5fb
b6110c3
 
 
 
 
 
 
 
2a87a37
 
 
c992804
 
 
 
 
2a87a37
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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)