Spaces:
Runtime error
Runtime error
Download app.py from rianders/Dynamiradio: direct link, hf CLI and curl.
- Browser
- Download file 661 Bytes
-
https://huggingface.co/spaces/rianders/Dynamiradio/resolve/main/app.py
- Command line
-
hf download hf://spaces/rianders/Dynamiradio/app.py
-
curl -L -o app.py https://huggingface.co/spaces/rianders/Dynamiradio/resolve/main/app.py
661 Bytes
| import gradio as gr | |
| from pprint import pprint | |
| def update_list(current_list): | |
| if not current_list: | |
| current_list = [] | |
| new_item = f"Item {len(current_list) + 1}" | |
| current_list.append(new_item) | |
| return current_list | |
| with gr.Blocks() as demo: | |
| with gr.Row(): | |
| button = gr.Button("Add Item") | |
| radio = gr.Radio(label="Items List", choices=[]) | |
| state = gr.State([]) # Initialize state | |
| # When button is clicked, update the list | |
| button.click(fn=update_list, inputs=state, outputs=state) | |
| # Update the radio options when the state changes | |
| state.change(fn=lambda x: x, inputs=state, outputs=radio) | |
| demo.launch() |