pyscript: Examples dont work on http://localhost:8080 due to incorrect path to pyscript.js build folder

Checklist

  • I added a descriptive title
  • I searched for other issues and couldn’t find a solution or duplication
  • I already searched in Google and didn’t find any good information or help

What happened?

Platforms: Both Ubuntu 22.95 LTS and macOS Monterey

What happened: After installing npm package rollup globally, cloning the repository, executing ‘make setup’, ‘make examples’ and ‘npm run dev’, the examples start page is displayed at localhost:8080. However on clicking on any example, the page for the example shows only the Python code but doesn’t execute it. For example, the page localhost:8080/bokeh.html displays the following:

- bokeh - numpy Bokeh Example import json import pyodide from js import Bokeh, console, JSON from bokeh.embed import json_item from bokeh.plotting import figure from bokeh.resources import CDN # create a new plot with default tools, using figure p = figure(plot_width=400, plot_height=400) # add a circle renderer with x and y coordinates, size, color, and alpha p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=15, line_color="navy", fill_color="orange", fill_alpha=0.5) p_json = json.dumps(json_item(p, "myplot")) Bokeh.embed.embed_item(JSON.parse(p_json))

What should happen: It should run the python code for that example.

Looking at the page source shows that it is looking for the pyscript.js build folder in the wrong place. The relevant line of the page source (taken from view-source:http://localhost:8080/bokeh.html) is:

<script defer src="../build/pyscript.js"></script>

Following the link to …/build/pyscript.js gives the following page content:

404 Not Found /home/mads/MDDev/pyscriptProj/pyscript/pyscriptjs/examples/build/pyscript.js` (rollup-plugin-serve)

In other words, it expects the build folder to be under examples, which is easily confirmed - on copying the build folder from …/build to examples/build, ALL the examples run. The reason is also clear - since the ROOT folder being served as localhost:8080 points to ‘examples’, it is not possible to go up one level with relative path. This issue is not there for the live website as explicit URLs are provided there. One possible solution is to serve the root as being one level higher than examples (with a suitable index.html).

What browsers are you seeing the problem on? (if applicable)

Firefox, Chrome

Console info

No response

Additional Context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

@marimeireles I’ll be happy to take care of the fix.