shiny.App#

class shiny.App(ui, server, *, static_assets=None, debug=False)#

Create a Shiny app instance.

Parameters
  • ui (Union[htmltools._core.RenderedHTML, Callable[[starlette.requests.Request], Union[htmltools._core.Tag, htmltools._core.TagList]]]) – The UI definition for the app (e.g., a call to page_fluid() or page_fixed(), with layouts and controls nested inside). You can also pass a function that takes a Request and returns a UI definition, if you need the UI definition to be created dynamically for each pageview.

  • server (Callable[[shiny.session._session.Inputs, shiny.session._session.Outputs, shiny.session._session.Session], None]) – A function which is called once for each session, ensuring that each app is independent.

  • static_assets (Union[str, PathLike[str], None]) – An absolute directory containing static files to be served by the app.

  • debug (bool) – Whether to enable debug mode.

Example

from shiny import *

app_ui = ui.page_fluid("Hello Shiny!")

def server(input: Inputs, output: Outputs, session: Session):
    pass

app = App(app_ui, server)

Methods

init_starlette_app()

run(**kwargs)

Run the app.

stop()

Stop the app (i.e., close all sessions).

Attributes

lib_prefix

A path prefix to place before all HTML dependencies processed by register_web_dependency().

sanitize_error_msg

The message to show when an error occurs and SANITIZE_ERRORS=True.

sanitize_errors

Whether or not to show a generic message (SANITIZE_ERRORS=True) or the actual message (SANITIZE_ERRORS=False) in the app UI when an error occurs.

ui

server