shiny.run_app(app='app:app', host='', port=8000, autoreload_port=0, debug=False, reload=False, ws_max_size=16777216, log_level=None, app_dir='.', factory=False, launch_browser=False)#

Starts a Shiny app. Press Ctrl+C (or Ctrl+Break on Windows) to stop.

  • app (Union[str, App]) – The app to run. The default, app:app, represents the “usual” case where the application is named app inside a file within the current working directory. In other cases, the app location can be specified as a <module>:<attribute> string where the :<attribute> is only necessary if the application is named something other than app. Note that <module> can be relative path to a .py file or a directory (with an file inside it); and in this case, the relative path is resolved relative to the app_dir directory.

  • host (str) – The address that the app should listen on.

  • port (int) – The port that the app should listen on. Set to 0 to use a random port.

  • autoreload_port (int) – The port that should be used for an additional websocket that is used to support hot-reload. Set to 0 to use a random port.

  • debug (bool) – Enable debug mode.

  • reload (bool) – Enable auto-reload.

  • ws_max_size (int) – WebSocket max size message in bytes.

  • log_level (Optional[str]) – Log level.

  • app_dir (Optional[str]) – Look for app under this directory (by adding this to the PYTHONPATH).

  • factory (bool) – Treat app as an application factory, i.e. a () -> <ASGI app> callable.

  • launch_browser (bool) – Launch app browser after app starts, using the Python webbrowser module.


The shiny run command-line interface (which comes installed with Shiny) provides the same functionality as this function.


from shiny import run_app

# Run ``app`` inside ``./``

# Run ``app`` inside ``./`` (or ``./myapp/``)

# Run ``my_app`` inside ``./`` (or ``./myapp/``)

# Run ``my_app`` inside ``../`` (or ``../myapp/``)
run_app("myapp:my_app", app_dir="..")
Return type