So I have created a example dash app in Django, but when I run the project, it says:
[16/Nov/2017 14:23:56] "GET /app/ HTTP/1.1" 200 1565
Not Found: /_dash-layout
Not Found: /_dash-dependencies
[16/Nov/2017 14:23:57] "GET /_dash-layout HTTP/1.1" 404 2188
[16/Nov/2017 14:23:57] "GET /_dash-dependencies HTTP/1.1" 404 2206
Not Found: /_dash-routes
[16/Nov/2017 14:23:57] "GET /_dash-routes HTTP/1.1" 404 2188
Here is dashboard.py:
from random import randint
import dash
import dash_core_components as dcc
import dash_html_components as dhc
def dispatcher(request):
'''
Main function
@param request: Request object
'''
app = _create_app()
params = {
'data': request.body,
'method': request.method,
'content_type': request.content_type
}
with app.server.test_request_context(request.path, **params):
app.server.preprocess_request()
try:
response = app.server.full_dispatch_request()
except Exception as e:
response = app.server.make_response(app.server.handle_exception(e))
return response.get_data()
def _create_app():
''' Creates dash application '''
app = dash.Dash(csrf_protect=False)
# app.config.update(
# {'routes_pathname_prefix': '/', 'routes_pathname_prefix': '/app/'}
# )
app.layout = dhc.Div(children=[
dcc.Graph(
id='main-graph',
figure={
'data': [{
'name': 'Some name',
'mode': 'line',
'line': {
'color': 'rgb(0, 0, 0)',
'opacity': 1
},
'type': 'scatter',
'x': [randint(1, 100) for x in range(0, 20)],
'y': [randint(1, 100) for x in range(0, 20)]
}],
'layout': {
'autosize': True,
'scene': {
'bgcolor': 'rgb(255, 255, 255)',
'xaxis': {
'titlefont': {'color': 'rgb(0, 0, 0)'},
'title': 'X-AXIS',
'color': 'rgb(0, 0, 0)'
},
'yaxis': {
'titlefont': {'color': 'rgb(0, 0, 0)'},
'title': 'Y-AXIS',
'color': 'rgb(0, 0, 0)'
}
}
}
}
)
])
return app
if __name__ == '__main__':
app = _create_app()
app.run_server()
and here is the views.py:
def index(request, **kwargs):
''' '''
return HttpResponse(app.dashboard.dispatcher(request))