Skip to content

404 error prevents serving static dash components on Windows #529

@austindonnelly

Description

@austindonnelly

When running on Windows, with PLOTLY_DASH = {"serve_locally": True}, I get a 404 Not Found HTTP error when requesting any of the static components, eg:
curl -X GET -v http://localhost:8000/static/dash/component/dash/html/dash_html_components.min.js
returns a 404 error page.

This is because DashComponentFinder compares a fragment of URL path (with / separators) against a local filesystem path which on Windows uses \. The comparison fails, so the static files are not served.

The fix is to convert the URL path fragment to match the local system's slash-preference, so that they can be directly compared.
The edit looks a bit like this:

https://github.com/GibbsConsulting/django-plotly-dash/blob/e6dd41ded4fd0236a0b387a59061dc96fce58109/django_plotly_dash/finders.py#L135C1-L136C1

    component_path = str(Path("dash/component/%s" % component_name))

This uses pathlib.Path to convert from dash/component/some/url/path to dash\component\some\url\path on Windows, while leaving it unmodified on Linux.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions