Deployment
Stateless Framework
  • Stateless server keeps no state information
  • Using a stateless file server, the client must,specify complete file names in each request specify location for reading or writing re-authenticate for each request
  • Pros
  • Multiple Servers
  • gunicorn will check which process isn't busy running a callback and send the new callback request to that process
  • a few processes can balance the requests of 10s or 100s of concurrent user
  • import dash
    import dash_html_components as html
    import dash_core_components as dcc
    
    external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
    
    app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
    
    server = app.server
    
    app.layout = html.Div([
        html.Div(dcc.Input(id='input-on-submit', type='text')),
        html.Button('Submit', id='submit-val', n_clicks=0),
        html.Div(id='container-button-basic',
                 children='Enter a value and press submit')
    ])
    
    
    @app.callback(
        dash.dependencies.Output('container-button-basic', 'children'),
        [dash.dependencies.Input('submit-val', 'n_clicks')],
        [dash.dependencies.State('input-on-submit', 'value')])
    def update_output(c, v):
        return 'The input value was "{}" and the button has been clicked {} times'.format(
            v,
            c
        )
    
    
    if __name__ == '__main__':
        app.run_server(debug=True)
            
    gunicorn app:server --workers 8
            
    Embedding Dash App in Public Websites
    /* index.htm */
    <!DOCTYPE html>
    <html>
    <body>
    
    <iframe src="http://localhost:8000" width=700 height=600>
    
    </body>
    </html>
            
    Reference
  • Geeksforgeeks