Skip to content
Snippets Groups Projects
app.py 2.34 KiB
# Run this app with `python app.py` and
# visit http://127.0.0.1:8050/ in your web browser.
import json

import dash
import dash_bootstrap_components as dbc
from dash import dcc, html

from callbacks import register_callbacks
from pages.application.application import Application, Model, View
from utils import extract_data

app = dash.Dash(external_stylesheets=[dbc.themes.LUX], suppress_callback_exceptions=True)

#################################################################################
############################# Layouts ###########################################
#################################################################################
models_data = open('data_retriever.json')
data = json.load(models_data)["data"]

#For home directory
page_home = dbc.Row([])
#For course directory
page_course = dbc.Row([])
#For the application
names_models, dict_components = extract_data(data)
model_application = Model(names_models, dict_components)
view_application = View(model_application)
page_application = Application(view_application)

app.layout = html.Div([
    dcc.Location(id='url', refresh=False),
    html.Nav(id='navbar-container', 
            children=[dbc.NavbarSimple(
                            children=[
                                dbc.NavItem(dbc.NavLink("Home", id="home-link", href="/")),
                                dbc.NavItem(dbc.NavLink("Course", id="course-link", href="/course")),
                                dbc.NavItem(dbc.NavLink("Application on explainable AI", id="application-link", href="/application")),
                            ],
                            brand="FX ToolKit",
                            color="primary",
                            dark=True,)]),    
    html.Div(id='page-content')
])

#################################################################################
################################# Callback for the app ##########################
#################################################################################
register_callbacks(page_home, page_course, page_application, app)

#################################################################################
################################# Launching app #################################
#################################################################################
if __name__ == '__main__':
    app.run_server(debug=True)