Create a Shinylive sharelink for Python Shiny apps
shinylive_py_link.Rd
Generates a shareable URL for Python Shiny applications that can run in the browser using Shinylive. The app files are encoded and embedded in the URL.
Arguments
- files
Named list where names are filenames and values are file content as character strings. For single-file apps, can also pass a character string as the app.py content.
- mode
Shinylive mode: "editor" (show code editor) or "app" (show app only)
- header
Logical. Whether to show header in app mode (default: TRUE)
- base_url
Custom Shinylive base URL. If NULL, uses default Shinylive URL
Examples
# Simple single-file Python Shiny app
app_code <- '
from shiny import App, render, ui
app_ui = ui.page_fluid(
ui.h2("Hello Shinylive!"),
ui.input_slider("n", "N", 0, 100, 20),
ui.output_text_verbatim("txt"),
)
def server(input, output, session):
@output
@render.text
def txt():
return f"n*2 is {input.n() * 2}"
app = App(app_ui, server)
'
link <- shinylive_py_link(app_code, mode = "app")
print(link)
#>
#> ── Shinylive Python App ──
#>
#> <https://shinylive.io/py/app/#code=NobwRAdghgtgpmAXGKAHVA6VBPMAaMAYwHsIAXOcpMAHQgDMAnYmAAgGcALASwm1e4xUxRmVYBBdHlaNKAEziNpAV2506aVAH1VrALytVWKAHM4W+gBtVcgBR1Wjw9wycATPbAAJOJcvFWAGUePktuADc4AEIaMABKPAcnI15UZTItdjCFRk8IWOlYgDkC1gAGaQBGMorWNzKEpMcjYnS0jIoADwzIxgAjKDJBTzJu2MaIOPUIBXoORV7bVPTpVrJ26XY4dnZuUjjEJtYAATX2o+PZGcUMLrIj2dZRslsDo6cZODJlRghWeliEAAVG4BOxWCBlmQMBBXqwgXUAL6xaaafQSdC2TQ6bibBaKKYQfBgMjYVAIZB3MCIgC6QA>
#>
#> Files (1):
#> app.py
#>
#> Engine: "Python"
#> Mode: "app"
# Multi-file Python Shiny app
files <- list(
"app.py" = app_code,
"utils.py" = "def helper_function(x):\n return x * 2",
"data.csv" = "x,y\n1,2\n3,4\n5,6"
)
link <- shinylive_py_link(files, mode = "editor")