Zhiguang Huo (Caleb)
Thursday Oct 26th, 2023
reference: https://shiny.posit.co/py/docs/install.html
pip install --upgrade pip wheel
pip install shiny
pip install --upgrade shiny htmltools
cd your_working_directory ## go to your working directory
shiny create . ## This will create a basic Shiny application in the current directory, in a file named app.py.
shiny run --reload
follow the instruction on https://www.shinyapps.io/admin/#/dashboard
pip install rsconnect-python
rsconnect add \
--account biostatisticscomputing \
--name biostatisticscomputing \
--token 9C753A57C8E5CE5E00F92F109C0B172B \
--secret <SECRET>
rsconnect deploy shiny path/to/your/app --name biostatisticscomputing --title your-app-name
from shiny import App, ui
# Part 1: ui ----
app_ui = ui.page_fluid(
"Hello, world!",
)
# Part 2: server ----
def server(input, output, session):
...
# Combine into a shiny app.
# Note that the variable must be "app".
app = App(app_ui, server)
from shiny import App, ui
app_ui = ui.page_fluid(
ui.input_slider("n", "Choose a number n:", 0, 100, 40),
ui.output_text_verbatim("txt")
)
def server(input, output, session):
pass
app = App(app_ui, server)
from shiny import ui, render, App
app_ui = ui.page_fluid(
ui.input_slider("n", "N", 0, 100, 40),
ui.output_text_verbatim("txt"),
)
def server(input, output, session):
@output
@render.text
def txt():
return f"n*2 is {input.n() * 2}"
# This is a shiny.App object. It must be named `app`.
app = App(app_ui, server)
Will follow close to this tutorial: