’s Dash Server

This is a simple example how to run dash by in CoCalc. This is taken from the dash introduction.

  1. Create a file named

    import os
    import dash
    import dash_core_components as dcc
    import dash_html_components as html
    import as px
    import pandas as pd
    # the next 4 lines are CoCalc specific
    port = 6767
    project_id = os.environ['COCALC_PROJECT_ID']
    base_url = f'/{project_id}/port/{port}/'
    dash_app = dash.Dash(name=__name__, url_base_pathname=base_url)
    # assume you have a "long-form" data frame
    # see for more options
    df = pd.DataFrame({
        "Fruit": ["Apples", "Oranges", "Bananas", "Apples", "Oranges", "Bananas"],
        "Amount": [4, 1, 2, 2, 4, 5],
        "City": ["SF", "SF", "SF", "Montreal", "Montreal", "Montreal"]
    fig =, x="Fruit", y="Amount", color="City", barmode="group")
    dash_app.layout = html.Div(children=[
        html.H1(children='Hello Dash'),
            Dash: A web application framework for your data.
        dcc.Graph(id='example-graph', figure=fig)
    if __name__ == '__main__':
        print(f'Open this link to access Dash.')
            f'You might have to refresh once or twice in case it takes time to load!\n\n'
        dash_app.run_server(debug=True, port=port, host='')
  2. in a Linux Terminal run:

  3. After 5-10 seconds of startup time, the interactive plot is accessible at the following URL:[PROJECT_ID]/port/6767/


You might have to refresh the page once or twice to get it loaded up properly!