Py-Shiny URL Parameters

Hi, I'm trying to figure out how get the parameters passed to the url of the route for a shiny application in PYTHON. There's lots of materials on how to do it in R, but I can't find any help for the Python version of Shiny.

So if the url is "http://localhost/path/?foo=bar"

I want to get foo=bar in the app.

Ben

Dear Ben,

I had the same problem and after some searching I found the following Github issue with a possible solution:
py-shiny/issues/323

I think the problem they are trying to solve is a bit more complicated, but a reply from @cpsievert states the following:

We don't officially expose clientData in the same public way yet, but FWIW, you can still access the same info today like this:

from urllib.parse import urlparse
from shiny import *

app_ui = ui.page_fluid(
    ui.output_text_verbatim("out"),
)

def server(input, output, session)
    @output()
    @render.text
    def out():
        search = session.input[".clientdata_url_search"]()
        return urlparse(search)


app = App(app_ui, server)

This code helped me and I hope it helps you with your problem.

Happy coding,
Michel

Awesome thank you!

Ben

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.