from shiny import App, Inputs, Outputs, Session, ui
= ui.page_fluid("Hello Shiny!")
app_ui
def server(input: Inputs, output: Outputs, session: Session):
pass
= App(app_ui, server) app
App
self, ui, server, *, static_assets=None, debug=False) App(
Create a Shiny app instance.
Parameters
ui : Tag | TagList | Callable[[
Request
], Tag | TagList] | Path-
The UI definition for the app (e.g., a call to
page_fluid
or similar, with layouts and controls nested inside). You can also pass a function that takes aRequest
and returns a UI definition, if you need the UI definition to be created dynamically for each pageview. server : Callable[[Inputs], None] | Callable[[Inputs, Outputs, Session], None] | None
-
A function which is called once for each session, ensuring that each session is independent.
static_assets : Optional[str | Path | Mapping[str, str | Path]] = None
-
Static files to be served by the app. If this is a string or Path object, it must be a directory, and it will be mounted at
/
. If this is a dictionary, each key is a mount point and each value is a file or directory to be served at that mount point. debug : bool = False
-
Whether to enable debug mode.
Examples
Attributes
Name | Description |
---|---|
lib_prefix | str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str |
sanitize_error_msg | str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str |
sanitize_errors | bool(x) -> bool |
Methods
Name | Description |
---|---|
call_pyodide | Communicate with pyodide. |
on_shutdown | Register a callback to be called when the app is shutting down. This can be useful for cleaning up app-wide resources, like connection pools, temporary directories, worker threads/processes, etc. |
run | Run the app. |
stop | Stop the app (i.e., close all sessions). |
call_pyodide
App.call_pyodide(scope, receive, send)
Communicate with pyodide.
Warning
This method is not intended for public usage. It’s exported for use by shinylive.
on_shutdown
App.on_shutdown(callback)
Register a callback to be called when the app is shutting down. This can be useful for cleaning up app-wide resources, like connection pools, temporary directories, worker threads/processes, etc.
Parameters
callback : Callable[[], None]
-
The callback to call. It should take no arguments, and any return value will be ignored. Try not to raise an exception in the callback, as exceptions during cleanup can hide the original exception that caused the app to shut down.
Returns
: Callable[[], None]
-
The callback, to allow this method to be used as a decorator.
run
**kwargs) App.run(
Run the app.
Parameters
****kwargs** :
object
= {}-
Keyword arguments passed to
run_app
.
stop
App.stop()
Stop the app (i.e., close all sessions).