Skip to content

Use of OS path concatenation instead of URL path concatenation in solara.server.flask #722

@masterbbud

Description

@masterbbud

In solara.server.flask line 202, in nbext(), the Flask url that is passed into send_from_directory is improperly formatted using os.path.sep, which is different on Linux/Windows. According to werkzeug, this function apparently actually accepts a URL path, not an OS path, which should always use / regardless of the system. (Currently on windows it uses \, which causes the path to be blocked by werkzeug under the hood).

I propose changing the following line:

return send_from_directory(directory, dir + os.path.sep + filename)

to either of the following:

return send_from_directory(directory / dir, filename)
return send_from_directory(directory, dir + "/" + filename)

Both fixes fix the issue when running on Windows.

See pallets/werkzeug#2927 for my issue on werkzeug's repo and the owners' response.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions