from shiny import run_app
# Run ``app`` inside ``./app.py``
run_app()
# Run ``app`` inside ``./myapp.py`` (or ``./myapp/app.py``)
"myapp")
run_app(
# Run ``my_app`` inside ``./myapp.py`` (or ``./myapp/app.py``)
"myapp:my_app")
run_app(
# Run ``my_app`` inside ``../myapp.py`` (or ``../myapp/app.py``)
"myapp:my_app", app_dir="..") run_app(
run_app
run_app(='app:app',
app='127.0.0.1',
host=8000,
port*,
=0,
autoreload_portreload=False,
=None,
reload_dirs=RELOAD_INCLUDES_DEFAULT,
reload_includes=RELOAD_EXCLUDES_DEFAULT,
reload_excludes=16777216,
ws_max_size=None,
log_level='.',
app_dir=False,
factory=False,
launch_browser=True,
dev_mode**kwargs,
)
Starts a Shiny app. Press Ctrl+C
(or Ctrl+Break
on Windows) to stop the app.
Parameters
app : str |
shiny
.App = 'app:app'-
The app to run. The default,
app:app
, represents the “usual” case where the application is namedapp
inside aapp.py
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 thanapp
. Note that<module>
can be a relative path to a.py
file or a directory (with anapp.py
file inside of it); and in this case, the relative path is resolved relative to theapp_dir
directory. host : str = '127.0.0.1'
-
The address that the app should listen on.
port : int = 8000
-
The port that the app should listen on. Set to 0 to use a random port.
autoreload_port : int = 0
-
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.
reload : bool = False
-
Enable auto-reload.
reload_dirs : Optional[
list
[str]] = None-
A list of directories (in addition to the app directory) to watch for changes that will trigger an app reload.
reload_includes :
list
[str] | tuple[str, …] = RELOAD_INCLUDES_DEFAULT-
List or tuple of file globs to indicate which files should be monitored for changes. Can be combined with
reload_excludes
. reload_excludes :
list
[str] | tuple[str, …] = RELOAD_EXCLUDES_DEFAULT-
List or tuple of file globs to indicate which files should be excluded from reload monitoring. Can be combined with
reload_includes
ws_max_size : int = 16777216
-
WebSocket max size message in bytes.
log_level : Optional[str] = None
-
Log level.
app_dir : Optional[str] = '.'
-
The directory to look for
app
under (by adding this to thePYTHONPATH
). factory : bool = False
-
Treat
app
as an application factory, i.e. a () ->callable. launch_browser : bool = False
-
Launch app browser after app starts, using the Python webbrowser module.
****kwargs** :
object
= {}-
Additional keyword arguments which are passed to
uvicorn.run
. For more information see Uvicorn documentation.
Tip
The shiny run
command-line interface (which comes installed with Shiny) provides the same functionality as shiny.run_app()
.