web sttarting

This commit is contained in:
2026-03-31 13:25:14 +05:00
parent 9cd6d83428
commit 59b3bcd0f4
30 changed files with 720 additions and 242 deletions

View File

@@ -1,36 +1,14 @@
import flet as ft
from view import ViewsHendler
import designer as ds
from info import AuthService
from router import setup_router
async def main(page: ft.Page):
page.title = "COPP"
page.bgcolor = ds.clolors.background
auth = AuthService(page)
_PUBLIC_ROUTES = {"/login"}
def route_change(e: ft.RouteChangeEvent):
page.run_task(_guarded_route_change, page.route)
async def _guarded_route_change(route: str):
if route not in _PUBLIC_ROUTES and not await auth.is_authenticated():
await page.push_route("/login")
return
page.views.clear()
view = ViewsHendler(page).get(route)
if view:
page.views.append(view)
else:
await page.push_route("/main")
page.update()
page.on_route_change = route_change
setup_router(page)
initial = page.route if page.route and page.route not in ("/", "") else "/login"
await page.push_route(initial)
await page.push_route("/main")
# export_asgi_app=True — Flet отдаёт ASGI-объект вместо запуска встроенного сервера.
# Uvicorn из CMD в Dockerfile подхватывает этот объект через «main:app».
app = ft.run(main, export_asgi_app=True, assets_dir="assets")
app = ft.run(main, export_asgi_app=True, assets_dir="assets")