I can start a Dash app by using app.run(debug=True)
Now, I need to send a filename to start the Dash App. The Dash App will load the file from the filename, and then do some calculations. How to do that/load filenames to start the app?
Did not find examples online
Emil
August 6, 2023, 9:51am
2
Depending on how you start the app, one option could be to use pass command line arguments? Another option could be environment variables.
AIMPED
August 6, 2023, 12:32pm
3
Another option could be a “config” file.
You could initiate your app with command line arguments. One of those arguments could be the path you are referring to.
EDIT: Actually I’m not sure if this works
What I did in the past is creating a config.py file which I import in the app.py.
something like this:
config.py:
my_path = '...'
app.py
import dash
import config
path_to_use = config.my_path
app = dash.Dash(__name__)
app.layout = html.Div(path_to_use)
app.run()
Sounds good to be a solution.
I can write the filename to configure file, and then Dash.app can load a fixed configure file.
I am wondering whether the run function below allows me to deliver a parameter like a string for filename to be loaded
app.run(
host='127.0.0.1',
port='42843',
proxy=None,
debug=None,
jupyter_mode: typing_extensions.Literal['inline',
'external',
'jupyterlab',
'tab',
'_none'] = None,
jupyter_width='100%',
jupyter_height=650,
jupyter_server_url=None,
dev_tools_ui=None,
dev_tools_props_check=None,
dev_tools_serve_dev_bundles=None,
dev_tools_hot_reload=None,
dev_tools_hot_reload_interval=None,
dev_tools_hot_reload_watch_interval=None,
dev_tools_hot_reload_max_retry=None,
dev_tools_silence_routes_logging=None,
dev_tools_prune_errors=None,
**flask_run_options
)
OK. I finally solve it.
I create a class as wrapper, where Dash app is an attribute in the object.
The instance of this class will load files first, and then start the Dash app