I have tried to find an answer to this, but have been unsuccessful. I think I lack the understanding as to what is going on.
I have a dash app, and am trying to deploy to a server. I've wrapped it in Flask and am using waitress to serve it up.
The app is simple, single page of HTML, couple of drop-downs, these drive a report. I've excluded the details.
My problem is I can't see how to trigger the app.layout (where the HTML sits) from the @app.route statement.
File layout is:
Code (skeletal)
# server.py
from waitress import serve
from myappname import app
serve(app, host='0.0.0.0', port=8050)
# myappname/__init__.py
from flask import Flask, render_template, request, session
from flask_session import Session
app = Flask(__name__)
import myappname.views
# myappname/views.py
from myappname import app
import flask
@app.route('/')
def index():
return flask.redirect('/myappname')
# myappname/myappname.py
import dash
import dash_core_components as dcc
import dash_html_components as html
import numpy as np
from dash.dependencies import Input, Output
from flask import Flask, render_template, request, session
from flask_session import Session
# ... various procedures
server = flask.Flask(__name__)
app = dash.Dash(__name__, server=server, url_base_pathname='/myappname')
app.layout = html.Div([
html.Div(rhubarb
),
html.Div([rhubarb,rhubarb
])
@server.route('/')
def index():
return flask.redirect('/myappname')
@app.callback(
Output('Elementy', 'options'),
[Input('Elementx', 'value')])
def fiddle1(selected_element):
return blah
@app.callback(
Output('Elementz', 'value'),
[Input('Elementy', 'options')])
def fiddle1(available_options):
return blah
I would appreciate if anyone could help. Thanks.
Wound up tossing most of the small files, put the app directly in init.py. server.py now reads:
from waitress import serve
from myappname import app
application = app.server
serve(application, host='0.0.0.0', port=8050)