Html file in panel convert not working

Hi,

I have been following the instructions on “Running Panel in the Browser with WASM” to convert a simple panel applications (e.g., slider widget) into a Pyodide.

First, I created the test.py file with my script for the slider widget. Then I ran “panel convert script.py --to pyodide-worker --out pyodide”, which was successful. Now I have the new pyodide folder with the .html & .js files.
Next, I ran “python -m http.server”, which I get “Serving HTTP on :: port 8000 (http://[::]:8000/) …”.

Now when I paste this “http://localhost:8000/pyodide/test.html” to my web browser, the app works great. But when I go to the pyodide folder and click on the test.html file, the app gets stuck in the loading phase.

Can someone help me resolve this?

1 Like

Hi @pouriya_j

Welcome to the community.

You can probably see the error/ cause if you open the browser developer console as described here.

Could you try doing it and pasting it here?

Hi @Marc,

This is what it says:

1 Like

I think the problem is that you cannot open the .html files directly from a file share due to browser security restrictions. That is why the Panel documentation shows how you serve via python -m http.server .... See javascript - Chrome can’t load web worker - Stack Overflow.

Could you try running panel convert script.py --out pyodide instead and see if it works? It may be slower to load without the web workers though.

1 Like

Thank you @Marc!
I ran the “panel convert script.py --out pyodide” and the .html file opens. I then tried using the web worker, and then moved the files (.html & .js) to Github pages, which also works!

So my problem was probably because of the web worker and browser restrictions.

2 Likes