test ract

This commit is contained in:
jze9
2026-05-14 16:47:58 +05:00
parent 0ac1c8a862
commit de78624495
36 changed files with 5877 additions and 254 deletions

View File

@@ -1,9 +1,18 @@
import os
from pathlib import Path
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
import flet as ft
import flet.fastapi as flet_fastapi
import designer as d
import theme_manager
from router import handle_route
from editor_page import router as editor_router
from public_pages import router as public_router
UPLOAD_DIR = os.getenv("FLET_UPLOAD_DIR", "/tmp/flet_uploads")
os.makedirs(UPLOAD_DIR, exist_ok=True)
async def main(page: ft.Page):
@@ -38,4 +47,19 @@ async def main(page: ft.Page):
await handle_route(page)
app = flet_fastapi.app(main)
# Custom routes must be registered on a WRAPPER app BEFORE mounting Flet.
# flet_fastapi registers a catch-all handler internally; anything added to
# the same app via include_router() ends up AFTER that catch-all and is
# never reached. The wrapper ensures our routes are checked first.
_flet = flet_fastapi.app(main, upload_dir=UPLOAD_DIR)
app = FastAPI()
app.include_router(public_router) # GET /article/{slug}
app.include_router(editor_router) # GET /editor/{id} + /api/* proxy
# Serve React editor static assets (JS/CSS chunks built by Vite)
_editor_dist = Path(__file__).parent / "editor-ui" / "dist"
if _editor_dist.exists():
app.mount("/editor-assets", StaticFiles(directory=str(_editor_dist)), name="editor-assets")
app.mount("/", _flet) # everything else → Flet SPA