I finally complete my app development, but the last hole I cannot resolve it out, wish someone to help me.
when I use this code on vps as my app.py:
import dash
import dash_bootstrap_components as dbc
from dash import Input, Output, dcc, html
from pages import project
app = dash.Dash(external_stylesheets=[dbc.themes.BOOTSTRAP], suppress_callback_exceptions=True, title="Tractor2")
...
server = app.server
if __name__ == "__main__":
app.run_server(debug=True)
I recived the error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at youremail@email.com to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
but when I try run this on the vps:
python3 FlaskApp/__init__.py
I got this feedback and it looks like correct:
Dash is running on http://127.0.0.1:8050/
* Serving Flask app '__init__'
* Debug mode: on
Then, I try another app.py like this:
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([
dcc.Input(id='my-id', value='initial value', type='text'),
html.Div(id='my-div')
])
@app.callback(
Output(component_id='my-div', component_property='children'),
[Input(component_id='my-id', component_property='value')]
)
def update_output_div(input_value):
return 'You\'ve entered "{}"'.format(input_value)
# nothing else needs changing except adding one more line code, like this
server = app.server
if __name__ == '__main__':
app.run_server(debug=True)
or this:
import dash
import dash_core_components as dcc
import dash_html_components as html
app = dash.Dash()
app.layout = html.Div(children=[
html.H1(children='Dash Tutorials'),
dcc.Graph(
id='example',
figure={
'data': [
{'x': [1, 2, 3, 4, 5], 'y': [9, 6, 2, 1, 5], 'type': 'line', 'name': 'Boats'},
{'x': [1, 2, 3, 4, 5], 'y': [8, 7, 2, 7, 3], 'type': 'bar', 'name': 'Cars'},
],
'layout': {
'title': 'Basic Dash Example'
}
}
)
])
server = app.server
if __name__ == '__main__':
app.run_server(debug=True)
both the 2 cods server run correct, but when I try my own code, I got error. sadly.
my folders is:
├── FlaskApp
│ ├── __init__.py
│ ├── model.py
│ ├── pages
│ │ ├── project.py
│ │ └── __pycache__
│ ├── __pycache__
│ └── tractor2.db
├── FlaskApp.wsgi
└── tractor2.db