Skip to content

Instantly share code, notes, and snippets.

@wch

wch/app.py Secret

Last active June 27, 2023 06:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wch/e62218aa28bf26e785fc6cb99efe8efe to your computer and use it in GitHub Desktop.
Save wch/e62218aa28bf26e785fc6cb99efe8efe to your computer and use it in GitHub Desktop.
Test app
from pathlib import Path
from shiny import ui, render, App, Inputs, Outputs, Session
app_ui = ui.page_fluid(
ui.row(
ui.column(
6, ui.input_slider("n", "Make a Shiny square:", min=0, max=6, value=2)
),
ui.column(
6,
ui.output_ui("images"),
),
)
)
def square(x: ui.TagChild, n: int) -> ui.Tag:
row = ui.div([x] * n)
return ui.div([row] * n)
def server(input: Inputs, output: Outputs, session: Session):
@output
@render.ui
def images() -> ui.Tag:
img = ui.img(src="logo.png", style="width: 40px;")
return square(img, input.n())
www_dir = Path(__file__).parent
app = App(app_ui, server, static_assets=www_dir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment