API/Application Deployment Options#
You can deploy a variety of APIs and applications using sub-commands of the
rsconnect deploy command.
api: WSGI-compliant APIs such as Flask and packages based on Flask
fastapi: ASGI-compliant APIs (FastAPI, Quart, Sanic, and Falcon)
dash: Python Dash apps
streamlit: Streamlit apps
bokeh: Bokeh server apps
All options below apply equally to the
Including Extra Files#
You can include extra files in the deployment bundle to make them available when your API or application is run by the RStudio Connect server. Just specify them on the command line after the API or application directory:
rsconnect deploy api flask-api/ data.csv
Since deploying an API or application starts at a directory level, there will be times
when some files under that directory subtree should not be included in the deployment
or manifest. Use the
--exclude option to specify files or directories to exclude.
rsconnect deploy dash --exclude dash-app-venv --exclude TODO.txt dash-app/
You can exclude a directory by naming it:
rsconnect deploy dash --exclude dash-app-venv --exclude output/ dash-app/
--exclude option may be repeated, and may include a glob pattern.
You should always quote a glob pattern so that it will be passed to
instead of letting the shell expand it. If a file is specifically listed as an extra
file that also matches an exclusion pattern, the file will still be included in the
deployment (i.e., extra files take precedence).
rsconnect deploy dash --exclude dash-app-venv --exclude “*.txt” dash-app/
The following shows an example of an extra file taking precedence:
rsconnect deploy dash --exclude “*.csv” dash-app/ important_data.csv
Some directories are excluded by default, to prevent bundling and uploading files that are not needed or might interfere with the deployment process:
.Rproj.user .env .git .svn .venv __pycache__ env packrat renv rsconnect-python rsconnect venv
APIs and Dash Apps#
When deploying a FastAPI or Flask API, or a Dash app, RStudio Connect needs to
locate the application object. The location of
the application object is called the entrypoint
and is specified in two parts, separated by a colon:
the module name and the object name (optional). For example,
app:app if both are specified; or simply
app if only the
module name is specified.
The module name is the name of a Python module that
contains the application. For example, if your application
code is in a file named
example.py in the application
directory, then the module name would be
The object name is the name of the application object in your Python code. In a Flask API, for example, the application is typically created by a line of code that looks like:
# example.py # ... app = Flask(__name__)
In this case, the application object is named
and the entrypoint would be
If the object_name is omitted, Connect will attempt to find a default application in the following order:
make_appare expected to be factory functions, which should take no arguments and should return a valid application object.
If you are using
rsconnect-python, the default entrypoint
app. If you put your code in
your application object is one of the defaults listed above,
the default entrypoint will work.
Otherwise, specify the entrypoint on the command line using
--entrypoint option. For example, if your
code is in the file
example.py and your application
object is named
rsconnect deploy api -n <saved server name> --entrypoint example:myapp ...
rsconnect deploy fastapi -n <saved server name> --entrypoint example:myapp ...
If you are creating a manifest.json file for later deployment, you can use:
rsconnect write-manifest api --entrypoint example:myapp ...
rsconnect write-manifest fastapi --entrypoint example:myapp ...
Streamlit and Bokeh Apps#
For Streamlit and Bokeh apps, the entrypoint is the name of the
Python file containing your app. For example, if your streamlit app's source
file is named
rsconnect deploy streamlit -n <saved server name> --entrypoint main.py ...
Creating a Manifest for Future Deployment#
You can create a
manifest.json file for an API or application, then use that
manifest in a later deployment. Use the
write-manifest command to do this.
write-manifest command will also create a
requirements.txt file, if it does
not already exist or the
--force-generate option is specified. It will contain
the package dependencies from the current Python environment, or from an alternative
Python executable specified in the
--python option or via the
Here is an example of the
rsconnect write-manifest api my-api/