Spaces:
Running
Running
File size: 1,317 Bytes
ac40033 1ef4e10 0fb23b8 1ef4e10 bc1cd44 1ef4e10 0fb23b8 bc1cd44 e1df50c 1ef4e10 e1df50c 1ef4e10 e1df50c 1ef4e10 e1df50c ac40033 e1df50c 1ef4e10 6b8b495 1ef4e10 e1df50c |
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
import gradio as gr
from pathlib import Path
from utils.logger import Logger
from components.login_page import LoginPage
from components.dashboard_page import DashboardPage
from utils.database import initialize_database
from config import conf
log = Logger()
initialize_database()
CSS_FILE = Path(__file__).parent / "assets" / "styles.css"
custom_css = CSS_FILE.read_text(encoding="utf-8")
def build_app() -> gr.Blocks:
"""
میسازد و wiring کل اپلیکیشن را انجام میدهد.
"""
demo = gr.Blocks(title=conf.APP_TITLE, css=custom_css)
with demo:
# حالت سراسری برنامه بهصورت gr.State
session_state = gr.State({})
gr.Markdown(f"### {conf.APP_TITLE}")
# صفحات
login_page = LoginPage()
dashboard_page = DashboardPage()
# اتصال رویدادها
login_page.register_callbacks(dashboard_page, session_state)
dashboard_page.register_callbacks(login_page, session_state, demo)
# صف پردازش گرادیو
demo.queue(default_concurrency_limit=50)
log.info("App Started.")
return demo
if __name__ == "__main__":
# try:
log.info("Launching App ...")
build_app().launch()
# except Exception as err:
# log.error(err) |