'Python panel (bokeh) server connection display empty html page without error message

I have a Django project where one view function start a bokeh server by a python script.

Popen(["panel", "serve", "/opt/bitnami/projects/blog/EnviAI/scripts/visz_pn_ssm_1.py", "--show"])

With another view, I try to connect to the server and display the dashboard from visz_pn_ssm_1.py .

def redirect_bokeh_server(request):

    
    session = pull_session(url="http://localhost:5006/visz_pn_ssm_1")
    script = server_session(model=None,session_id=session.id,url="http://localhost:5006/visz_pn_ssm_1")

    return render(request, 'dashboard_ssm.html', {'script' : script})

in my dashboard_ssm.html

<body>
    {{script | safe}}
</body>

From the console i get:
Starting Bokeh server version 2.4.2 (running on Tornado 6.1)
2022-04-03 08:26:03,800 User authentication hooks NOT provided (default user enabled)
2022-04-03 08:26:03,804 Bokeh app running at: http://localhost:5006/visz_pn_ssm_12022-04-03
08:26:03,804 Starting Bokeh server with process id: 269292022-04-03
08:26:06,550 WebSocket connection openedtest2022-04-03 08:26:07,762 ServerConnection created

But the page is empty?

The content of my panel script visz_pn_ssm_1.py:

import pandas as pd
import geopandas as gpd
import panel as pn
import hvplot.pandas
import pickle

pn.extension()
pn.config.js_files  = {'deck': 'https://unpkg.com/deck.gl@~5.2.0/deckgl.min.js'}
pn.config.css_files = ['https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.1/mapbox-gl.css']

with open ('/opt/bitnami/projects/data/filepath_ssm_user.pickl', 'rb') as temp:
    res = pickle.load(temp)
    
# ried soil samples 30m 17-19
gdf = pd.read_csv(f'/opt/bitnami/projects/data/tables/{res[0]}'
            ,)[['date', 'ssm']].dropna().reset_index(drop=True)
gdf['date'] = gdf['date'].astype('datetime64[ns]')

#Options for Widgets
years = gdf.date.dt.year.unique()

# Widgets
year_slider = pn.widgets.IntSlider(name = 'Year', start=int(years.min()), end=int(years.max()), value=int(years[0]))
@pn.depends(year_slider)

def plot_data(year_slider):
    data_select = gdf[gdf['date'].dt.year == year_slider]
    
    # Scatter Plot
    scatter = data_select.hvplot.scatter(
        x = 'date',
        y = 'ssm',
        title = f'Oberflächennahe Bodenfeuchte'
    )
    
    return scatter

# Non Parameter Attributes
title = 'Oberflächennahe Bodenfeuchte berechnet mithilfe von Convolutional Neuronal Networks aus Sentinel 1 & 2 & ERA 5 Satelliten Daten'

header_box = pn.WidgetBox(title,
                          year_slider, 
                          align="center"
                         )

# Plot Box
dashboard = pn.Row(header_box, plot_data)

# To start with panel serve script
dashboard.servable()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source