Flask Applications

This example uses Flask to make a model developed in Python available as a REST API in RStudio Connect, allowing other teams and tools to take advantage of the data science model developed in Python. In addition to serving the model, Flask is also used to serve a very simple web form to facilitate calls to the model.

The source code is available in this Git repository.

An example of the live application and REST API is available here.

Other Frameworks #

In addition to Flask, it is possible to take advantage of Flask extensions. For example, the popular flask-restx package can be used to automatically generate interactive documentation for your API. RStudio Connect knows how to host and serve that documentation when available.

Refer to the example code and a deployed API that includes this documentation. The user guide provides more details and examples.

Publishing Flask APIs #

Refer to the RStudio Connect user guide for more information on building and deploying models as Flask APIs. To publish, you can use the rsconnect-python package. This package is available to install with pip from PyPi. Once installed, a command line interface is available that allows you to publish to RStudio Connect from your favorite Python IDEs including PyCharm, VS Code, and others.