Support for initial load url parameters in an app
- Dominant language
- Python
- Stars
- 4.3k
- Forks
- 371
- Avg merge
- 26d 1h
- Merged PRs (30d)
- 1
Description
It would be useful to be provide support url parameters when an app loads in the browser. I was initially confused and thought the wave syntax use of `?` in markdown was equivalent to url parameters (see this [question](https://github.com/h2oai/wave/discussions/1853)).
This feature could be useful for a user clicking on a link to an app that has a bunch of user input fields. The initial values for the user inputs could be provided via query parameters in the link that was clicked. If the url parmeters could be accessed via `q.args` it means the same logic that handles user events in the app would also handle the url parameters.
As an example, an app named radio
```py
modes = ["Basic", "Advanced", "Admin"]
@app('/radio')
async def serve(q: Q):
q.page["form"] = ui.form_card(
box="1 1 4 7",
items=[ui.dropdown(
name="mode",
values=modes,
value=q.args.mode if q.args.mode else modes[0]
)])
if q.args.mode == 'Advanced':
# make other fields available for more advanced user input
```
This way the advanced user input fields cold be shown initially if the app is loaded in the browser with the following url `http://localhost:10101/radio?mode=Advanced`
Contributor guide
Research direction
Start at the Python @app route and the serve(q: Q) entry point shown in the issue, then trace how request arguments are populated. Use the /radio?mode=Advanced example to verify that the query value is available through q.args during the initial load and that the app can select its initial input state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100