Download and Extract a Standalone Shinylive Application
Source:R/peek.R
peek_standalone_shinylive_app.RdDownloads and extracts a standalone Shinylive application from a URL. The function
locates the application's app.json file, validates its structure, and extracts
all application files to a local directory. Works with both R and Python
Shinylive applications.
Arguments
- url
Character string. URL pointing to either:
A Shinylive app.json file directly
A directory containing app.json
The function will automatically append
"app.json"to directory URLs.- output_dir
Character string. Directory where the application files should be extracted. Defaults to
"converted_shiny_app". Will be created if it doesn't exist. If the directory already exists, files may be overwritten.
Value
An object of class "standalone_shinylive_app" containing:
List of extracted files and their contents
Source URL of the application
Output directory location
The object has a custom print method that displays:
Application type (R or Python)
Command to run the application
List of extracted files by type
File locations
File Structure
A valid Shinylive application should have an app.json file containing:
At least one application file (e.g.,
app.Rorapp.py)Optional supporting files (e.g., data files,
requirements.txt)File metadata including name, content, and type
Error Handling
The function will error with informative messages if:
No
app.jsonfile is found at the URLThe
app.jsonfile has invalid structureThe
app.jsonfile cannot be downloadedRequired application files are missing
See also
find_shinylive_app_json()forapp.jsonvalidationwrite_standalone_shinylive_app()for file extractionpeek_shinylive_app()for a more general-purpose download function
Examples
if (FALSE) { # interactive()
# Download from a direct app.json URL
app <- peek_standalone_shinylive_app(
"https://tutorials.thecoatlessprofessor.com/convert-shiny-app-r-shinylive/app.json"
)
# Download from a directory URL (app.json will be appended)
app <- peek_standalone_shinylive_app(
"https://tutorials.thecoatlessprofessor.com/convert-shiny-app-r-shinylive/",
output_dir = "my_local_app"
)
# Print shows how to run the application
print(app)
}