'Redirect django view to bokeh server startet with subprocess on webserver

I have a Django web server deployed on an AWS machine. I don't want to build a Django bokeh app. All I want to do is to display my dashboard which runs on the bokeh server in an HTML file which I can reach through an URL of my website.

In my views.py I start the bokeh server with:

import os
print("debug1")
os.system("panel serve /opt/bitnami/projects/blog/EnviAI/scripts/visz_pn_ssm_1.py")
print("debug2")
script = server_document("http://localhost:5006/visz_pn_ssm_1")
return render(request, 'ssm_results.html', {'script' : script})

In my console, I can see that the server is started successfully. The debug1 print is also printed. The problem I have is the code stops here and do nothing until I cancel the bokeh server. The debug2 statement is printed as I cancel the bokeh server. The problem is that the code will never get to the point that the return redirect to the actual bokeh server because I have to kill them?! What can I do?

EDIT:
Solve the problem with @sudden_appearance subprocess.Popen() solution.

from subprocess import Popen
Popen(["panel", "serve","--show","/opt/bitnami/projects/blog/EnviAI/scripts/visz_pn_ssm_1.py", "--log-level", "debug"])


Sources

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

Source: Stack Overflow

Solution Source