Serve files

How can I serve the content of a specific folder online?
Something like this:


The goal is for a user to see a list of all the available files in that folder and be able to download them. The last post about this topic was more than 2 years ago so I figured I’ll ask anew.

Thanks!

1 Like

Simon helped me with the following example for how to accomplish this using JSServe and AssetRegistry:

using JSServe, AssetRegistry

function create_link(parent, file)
    url = AssetRegistry.register(joinpath(parent, file))
    return JSServe.DOM.a(href=url, file)
end

function test_handler(session, req)
    path = pwd()

    dom = JSServe.DOM.div([JSServe.DOM.div(create_link(path, file)) for file in readdir(path)]...)

    return JSServe.DOM.div(dom)
end

app = JSServe.Application(test_handler, "0.0.0.0", 8081)
3 Likes