Skip to content

How do you suggest we retrieve querystring or route values? #68

Answered by picklelo
simonmesmith asked this question in Q&A
Discussion options

You must be logged in to vote

This isn't supported at the moment, but we have plans to add it soon. We have a ticket to track it here.

The design we had in mind currently that the render functions take in the query arguments. So if you had a blog page and you want the path to be /blog/<post_id> you could define your render function like:

def blog(post_id: pc.Var[str]):
  return pc.box(...)

Then you could add a route like

app.add_page(blog, path="/blog/:post_id")

For query parameters, we would make them accessible as kwargs.

def blog(post_id: pc.Var[str], **kwargs):
  ...

In the app state, we would provide some way to access the query parameters. So in the event handlers, maybe you could call self.get_query_params()

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@FHU-yezi
Comment options

@picklelo
Comment options

@matt-grain
Comment options

Answer selected by picklelo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants