wasm example
Embedded Shiny application
To display a running Shiny app, use a code block with {shinylive-python}
.
#| standalone: true
#| viewerHeight: 420
import shiny
# Define the UI
app_ui = shiny.ui.page_fluid(
shiny.ui.input_slider("num", "Choose a number:", min=1, max=100, value=50),
shiny.ui.output_text("result")
)
# Define the server logic
def server(input, output, session):
@output()
@shiny.render.text
def result():
return f"You selected: {input.num()}"
# Create the Shiny app
app = shiny.App(app_ui, server)