Exporting as HTML object

I have a Dash app that uses some callbacks for an interactive graph with some radio buttons, is it possible to export all of this as a HTML object? I want to host it somewhere for people to come and see but it would be only for selected users.

Here’s my code.


import matplotlib.pyplot as plt
from dash.exceptions import PreventUpdate
import plotly.io as pio
pio.renderers.default = "browser"
pio.renderers
from dash import Dash, dcc, html, Input, Output
import dash
import pandas as pd

path = r'C:\Users\T\22.csv'
df = pd.read_csv(path)
df.columns = df.columns.str.replace('Unnamed: 0', 'DateTimeUtc')
b_z = ['DK1','DK2','FI','NO1','NO2','NO3','NO4','NO5','SE1','SE2','SE3','SE4']

zone_dict = {'DK':'Denmark', 'FI':'Finland', 'NO':'Norway', 'SE':'Sweden' }
ID = 'DK'
zone_ID = zone_dict[ID]

app = dash.Dash(__name__)

app.layout = html.Div(children = [html.H1('Errors)'), 
                                  dcc.Checklist(id='my-checklist', options=[{'label': col, 'value': col} for col in df.columns[1:]],
        value=df.columns.tolist(),
        labelStyle={'display': 'inline-block'}
    ),
    dcc.Graph(id='my-line-graph', figure={}),
    
])


@app.callback(
    Output(component_id='my-line-graph', component_property='figure'),
    Input(component_id='my-checklist', component_property='value')
)
def update_plot(input_zone):
    if input_zone !=[]:
        figure = px.line(data_frame= df, x='DateTimeUtc', y= input_zone,  width=1900, height=900)
        figure.update_xaxes(rangeslider_visible=True) #ranges slider
        return figure
    else:
        raise PreventUpdate


if __name__ == '__main__':
    app.run_server(debug=False)

Hi @tg550 you would like to convert your app into a html? That’s not possible as far as I know.

Would you like to share the app internally with your colleagues or host it somewhere public, for example on render.com?

In order to restrict the access, you could add a user authentication.

I want to convert it to a html object. It will be hosted on my own server I can’t have it anywhere else.

As I said, you can’t convert it into a interactive html object.

You could use the forum search on how to deploy your app, because I think this is what you want to do in the end.

Ok then, if you’re certain there is no way, although I’ love to know why.

But like I said, it has to be hosted on my sever so I’ll have to find another solution. Thanks

Hello @tg550,

You can host it on an internal server. I’m not sure what the issue is exactly that you are facing.

There are a few ways to go about inserting it altogether. In an iframe, or have people navigate to it.

As far as Auth, there are ways to do that too.

1 Like

Authorisation issues are not something I need advice on thank you. I was simply asked to provide it as a HTML object for the next person who wants to host it with Hugo on a static site on a private server.

There is no issue with it running now, it runs beautifully on an internal server I host I just need an alternative packaging but if its not possible I’ll try something else.

Thanks