Hello, I am working on my dash app for my master’s final project and now I have a new problem I hope someone can help me with. I was recently able to upload a simple app in heroku without issues. The app had only one .py file. Now I have added some tabs to the app and therefore added complexity and additional files to it. It works fine locally in my Mac laptop. But when I try to create the app and upload it in Heroku it does not work. I think I know why it does not work but I don’t know how to fix it. While putting together the tabs in my dashboard using the Dash library, I had to create a file named dash_app.py in addition to the index.py file. The file dash_app.py has the following code:
import dash
import dash_bootstrap_components as dbc
external_stylesheets = [dbc.themes.BOOTSTRAP]
app = dash.Dash(__name__,external_stylesheets=external_stylesheets)
server = app.server
Notice how I have included HERE (and not in the index.py) the line: server = app.server
Having said the previous, the code for the index.py is included below. This file basically allows me to define the tabs I need in my dashboard. This was the only way it would work, otherwise, if I had everything in one file, i.e. index.py, the tabs would show but they would not work (in fact it would not show the contents associated with each tab). Here is the code for the index.py file:
import dash
from dash.dependencies import Input, Output
import dash_html_components as html
import dash_core_components as dcc
import dash_bootstrap_components as dbc
import my_callbacks
import dash_app
#app = dash.Dash() - I had to comment this line because of the issue mentioned before
dash_app.app.config['suppress_callback_exceptions'] = True
dash_app.app.layout = html.Div([
html.H1('Real State Prediction Web'),
dcc.Tabs(id="tabs-master", value='Description', children=[
dcc.Tab(label='Introduction', value='Introduction'),
dcc.Tab(label='Gallery', value='gallery'),
dcc.Tab(label='Reporting', value='Reporting'),
dcc.Tab(label='Analysis', value='Analysis')
]),
html.Div(id='tabs-content-master')
])
if _name_ == '__main__':
dash_app.app.run_server(debug=True)
So, to run the app locally I type in the terminal “python index.py” and it runs without a problem in Safari or Chrome… but I know the “Procfile” that needs to be created has to have in the top the name of the file where the code “server = app.server” was included. Whether I type “index” or “dash_app” (without the .py), it won’t work. If you have any idea as of why this it, please let me know… I am stuck in this part and can’t move forward (plus I am new to all this!!!)
Thank you, any feedback will be extremely valuable.
Jorge