Hi,
I'm trying to deploy a Dash app that is relatively large. As such, the functionality is split out into separate files/folders. Using an example taken from the Dash documentation, imagine it is locally contained in
./minimal_app/
-------> app.py
-------> another_file.py
where another_file.py contains some functionality we want to import into app.py, e.g.:
another_file.py
DEFAULT_STRING="this is the default string"
app.py
# taken (mostly) from Dash documentation
from dash import Dash, dcc, html, Input, Output, State
from another_file import DEFAULT_STRING
app = Dash(__name__)
app.layout = html.Div([
html.Div(dcc.Input(id='input-on-submit', type='text')),
html.Button('Submit', id='submit-val', n_clicks=0),
html.Div(id='container-button-basic',
children='Enter a value and press submit')
])
@app.callback(
Output('container-button-basic', 'children'),
Input('submit-val', 'n_clicks'),
State('input-on-submit', 'value')
)
def update_output(n_clicks, value):
if n_clicks >= 1:
return 'The input value was "{}" and the button has been clicked {} times'.format(
value,
n_clicks
)
else:
return DEFAULT_STRING
if __name__ == '__main__':
app.run_server(debug=True)
If I deploy this, when I load up the app I receive a page that says:
An error has occurred
The application exited before accepting connections. Contact the author or review the logs for more information.
Removing the import fixes that error.
Is there some way/example of using relative imports in a dash app hosted using python-rsconnect?