diff --git a/app.py b/app.py new file mode 100644 index 0000000..1a96788 --- /dev/null +++ b/app.py @@ -0,0 +1,36 @@ +"""Main Application File""" + +import dash +from dash import Output, Input, dcc, html +from appconfig import appconfig + +# Initialize the Dash app +app = dash.Dash(__name__) + +# Define the layout of the app +app.layout = html.Div( + children=[ + html.H1(children="Hello Dash"), + html.Div( + children=""" + Dash: A web application framework for Python. + """ + ), + dcc.Input(id="input-text", value="initial value", type="text"), + html.Div(id="output-text"), + ] +) + + +# Define callback to update the output text +@app.callback( + Output(component_id="output-text", component_property="children"), + [Input(component_id="input-text", component_property="value")], +) +def update_output_div(input_value): + return f"You've entered: {input_value} and {appconfig.DASH_APP.APP_TITLE}" + + +# Run the app +if __name__ == "__main__": + app.run_server(debug=True) diff --git a/appconfig.py b/appconfig.py new file mode 100644 index 0000000..65af61d --- /dev/null +++ b/appconfig.py @@ -0,0 +1,16 @@ +"""This module reads the configuration file and converts it to a namespace.""" + +import tomllib +from types import SimpleNamespace + +def dict_to_namespace(d): + """Convert a dictionary to a namespace.""" + for key, value in d.items(): + if isinstance(value, dict): + d[key] = dict_to_namespace(value) + return SimpleNamespace(**d) + +with open('config.toml', 'rb') as f: + config_dict = tomllib.load(f) + +appconfig = dict_to_namespace(config_dict) \ No newline at end of file diff --git a/appconfig.toml b/appconfig.toml new file mode 100644 index 0000000..d403b5b --- /dev/null +++ b/appconfig.toml @@ -0,0 +1,14 @@ +[DASH_APP] +APP_TITLE = "MTA DASH" +HEAD_TITLE = "taruma-mtadash | MTA DASH" +UPDATE_TITLE = "Updating..." +DEBUG = false +ALIAS = "taruma-mtadash" + +[TEMPLATE] +WATERMARK_SOURCE = "" +THEME = "MATERIA" + +VERSION = "v1.2.0" +GITHUB_LINK = "https://github.com/taruma/anfrek" +GITHUB_REPO = "taruma/anfrek" \ No newline at end of file