2
votes

I am new to plotly and dash I have a few problems: I got this message: Serving Flask app "dash" (lazy loading)

  • Environment: production WARNING: Do not use the development server in a production environment. Use a production WSGI server instead.
  • Debug mode: off

in addition the webpage in which I insert the web result present the original graph unless I restart my computer or change the port in app.run_server() this is my code :

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
import numpy as np

app = dash.Dash()

np.random.seed(42)
random_x = np.random.randint(1,101,100)
random_y = np.random.randint(1,101,100)

app.layout = html.Div([
    dcc.Graph(
        id='scatter3',
        figure={
            'data': [
                go.Scatter(
                    x = random_x,
                    y = random_y,
                    mode = 'markers',
                    marker = {
                        'size': 12,
                        'color': 'rgb(51,204,153)',
                        'symbol': 'pentagon',
                        'line': {'width': 2}
                        }
                )
            ],
            'layout': go.Layout(
                title = 'Random Data Scatterplot',
                xaxis = {'title': 'Some random x-values'},
                yaxis = {'title': 'Some random y-values'},
                hovermode='closest'
            )
        }
    )
])

if __name__ == '__main__':
    app.run_server()
1
The message looks like the default log output. And since you haven’t defined any callbacks, the page is static. What did you expect/intend? - emher
I expected to change the graph color /data /type and see change accordingly - zachi
Maybe i misunderstood, are you making changes to the code and running it again? - emher
yes I am practicing, I would like to create graph and change the code to switch type colors and see again and again the changes, I can change port in the app.run_server() - zachi
You only need to use callbacks to make the page interactive, i.e. if you want change to happen without re-running the app. The app should update when you change the code (without reboot/port change), but i have also experienced similar problems on Windows. Now i use Linux, and the problem is gone. - emher

1 Answers

0
votes

Have you tried using waitress? Assuming py_file is the name of your file, try,

waitress-serve my_file:app.server

Do check out this thread, very similar to your question, https://community.plotly.com/t/production-and-development-enviroments/21348/3.