Hi,
I’m facing a strange issue for which I couldn’t find any solution. I have a dash app with the structure
| -- src
- __init__.py
- app.py
- index.py
| -- pages
- home.py
- contact.py
| -- home_input
- __init__.py
- input_components.py
- input_layout.py
| -- home_results
- __init__.py
- results_components.py
- results_layout.py
| -- home_settings
- __init__.py
- settings_components.py
- settings_layout.py
| -- rmsd
- __init__.py
- rmsd_components.py
- layout.py
| -- assets
| -- components
- __init__.py
- footer
- navbar
- login
| -- data
| -- utils
- __init__.py
- common_functions.py
- settings.py
In app.py I have:
app = Dash(__name__, external_stylesheets=[dbc.themes.LUX], suppress_callback_exceptions=True, title="CoDi", use_pages=True, assets_folder=script_path + 'assets',
pages_folder="src/pages",
meta_tags=[
{
'name': 'viewport',
'content': 'width=device-width, initial-scale=1'
}
])
server = app.server
my index.py:
from src.app import app
# CALLBACKS
from src.pages.home_input.input_components import *
from src.pages.home_results.results_components import *
from src.pages.home_settings.settings_components import *
from src.pages.home_settings.background_components import *
from src.pages.rmsd.rmsd_components import *
app.layout = html.Div([
html.Div([navbar.navbar]),
page_container,
dcc.Store(id='subunit_figure', storage_type='session'),),
dcc.Store(id='single_data_names', storage_type='session'),
dcc.Store(id='protein_data_names', storage_type='session'),
html.Div([footer.footer]),
], className="dash-bootstrap")
register_callbacks(app)
register_callbacks1(app)
register_callbacks2(app)
register_long_callbacks1(app)
register_callbacks_rmsd(app)
if __name__ == '__main__':
# app.run(debug=False, use_reloader=False)
app.run_server(debug=False, port=8022, use_reloader=False, host='127.0.0.1')
When I run it locally everything works fine, but when I run it via gunicorn “gunicorn app:server --workers 4” I just get the main page but without navbar, footer and especially the page_container is not displayed. The same problem I have when I want to put it onrender or on pythonanywhere.
I tried a lot of different stuff and sometimes I managed to get the navbar and footer into it, but the page_container is never shown.
I also tried to add requests_pathname_prefix=‘/myapp/’, routes_pathname_prefix=‘/myapp/’. It didn’t help.
Any suggestion on what I can do? Is it the paths to the pages that are not managed with gunicorn ?
Thank you so much for the help!
Best,
Filip