I’m successfully able to host my panel on Heroku, using the instructions here, but can’t get it to work on my preferred service: Netlify.
The run command that I try looks like this: python -m panel serve test_panel.py --address 0.0.0.0 --port 8000 --allow-websocket-origin=checkout-bi.netlify.app
I have tried with and without address and port assigned with the same result.
The deploy log at Netlify looks like this, so it doesn’t give an error, but still, I am unable to access the app.
5:22:06 PM: 2022-07-28 15:22:06,924 Starting Bokeh server version 1.4.0 (running on Tornado 5.1.1)
5:22:06 PM: 2022-07-28 15:22:06,925 User authentication hooks NOT provided (default user enabled)
5:22:06 PM: 2022-07-28 15:22:06,927 Bokeh app running at: http://0.0.0.0:8000/panel_test
5:22:06 PM: 2022-07-28 15:22:06,928 Starting Bokeh server with process id: 1299
On the site (checkout-bi.netlify.app) this text displayed: Not Found - Request ID: 01G92Q3XZZK4VR7HJGKDF5WRC9
Has anyone successfully deployed a panel app with netlify before? Any ideas how I could solve this?
Thanks for your response! Sure, I’ll give it a go:
Put this test_panel.py-file in a github repo
import panel as pn
import plotly.express as px
import numpy as np
def test_plot():
x = np.linspace(0, 10, 100)
fig = px.line(x=x, y=np.sin(x))
return fig
pn.Column(test_plot).servable()
Also, put a requirements.txt there:
numpy
plotly
panel
In netlify on the overview page, Add new site > Import an existing project > Select github as source > Select newly created repo
Under Domain management > Domains > Custom domains, for the newly created app, select Options > Edit site name and put in my-test-panel
Under site settings > Build and deploy > Continuous deployment > Base settings, put the following under Build command: python -m panel serve panel_test.py --address 0.0.0.0 --port 8000 --allow-websocket-origin=my-test-panel.netlify.app
Go to Deploys > Trigger deploy > Deploy site and follow the log
What you would be able to deploy then on Netlify are static output from hvPlot, HoloViews or Panel. Alternatively dynamic web pages created using PyScript+Panel. PyScript is in alpha, so it might or might not work for you.
As I understand it, the provided example would be considered static. I seem to remember exporting/saving a similar script to html and then just opening the html file with my web browser. As I recall, it was even able to save some input states and corresponding graph data before the amount of input combinations got too high.
Ok, for an static site you need to save the dashboard instead of using servable. No additional configuration is needed in netlify. You only need to save the HTML generated by panel in the github repository. Here below you can check the modified code, the repository and the netlify site
import panel as pn
import plotly.express as px
import numpy as np
def test_plot():
x = np.linspace(0, 10, 100)
fig = px.line(x=x, y=np.sin(x))
return fig
pn.Column(test_plot).save('index.html')
I faced the similar issue while publishing Panel application to netlify…
Then i came across this documentation https://panel.holoviz.org/user_guide/Running_in_Webassembly.html
you can put this command in netlify build panel convert script.py --to pyodide-worker --out pyodide --requirements ./requirements.txt command… & configure the publish pyodide directory for serving the generated html file.
there is absolutely no need of any server running…