Shiny for Python

Shiny for Python is a web application framework for Python.

Get started by following the Shiny for Python Getting Started Guide, then visit the examples page.

You can deploy Shiny for Python applications to Posit Connect using rsconnect-python 1.10.0 or later and the command:

rsconnect deploy shiny -n my-server my-shiny-app/

Tracking visits

Connect records visits to Shiny applications and lets you see:

  • Which applications were viewed
  • When the applications were viewed
  • Who viewed the application
  • The length of each session

An overview of recent activity is available in the Connect dashboard. See the Content Settings panel section to learn more.

Details about each visit are available through Connect Server API instrumentation endpoints. Perform your own analysis using the results from these endpoints. Code examples showing how to obtain this data can be found in the User Activity section of the Posit Connect Server API Cookbook.

User meta-data

Shiny applications can access the username and the names of groups of the current logged in user through the session parameter of the server function.

def server(input, output, session):
    def user():
        return session.user

    def groups():
        return " ".join(session.groups or [])

Your application can use this information to display customized messages or to enable functionality for a specific subset of users.

User and group uniqueness

Most environments have unique usernames where each session.user identifies a single user and session.groups identifies the name of the groups the user is a member of.

However, in large organizations with hundreds of users and groups, this might not be true. See the Credentials for Content section in the Admin Guide for more information.

Specifying protocols

Connect provides a wide variety of techniques to keep the data in the web browser synchronized. The preferred technique, and the one most widely used, is the use of WebSockets. If WebSockets are not supported, either by some intermediate network between the server and your client or by your client’s web browser, then a fallback protocol will be used.

To change the available protocols from the client, open a Shiny application and press the keyboard shortcut: Ctrl+Alt+Shift+A (or, from a Mac: control+option+shift+A). This opens a window that allows you to select or clear any of the available protocols. After you confirm the changes, these settings are saved in your browser for future visits to this server.

If you are actively visiting an application, refresh the browser page or tab in order for the new settings to take effect within your session. These settings last until you explicitly change them again. They only effect the browser in which this action is performed.