Feature Request: Load Demo App on Colab without Port Forwarding Trick

Open
#376 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
jupyter-notebook, python

Research direction

Start by reviewing the linked Gradio Colab example and the current ngrok setup in the issue. Determine how a Shiny for Python app could run in Google Colab with a nested display and no port-forwarding workaround; done means a getting-started notebook can launch and display the demo app without ngrok.

Written by the indexing model from the issue text.

Description

Desired Feature

I'm not sure this is possible, but it would be nice to have a getting starting example in a Google Colab notebook. This is offered by gradio ( https://gradio.app/docs/ ) via a "Open with Colab" badge:

gradio-docs-example

From here, the notebook can be launched and iterated upon with a nested display:

https://colab.research.google.com/github/gradio-app/gradio/blob/main/demo/hello_world/run.ipynb#scrollTo=2.8891853944186117e%2B38

gradio-docs-nested-colab

Current Solution

At the moment, the only way to view a Shiny for Python app with Google Colab is to use ngrok to port forward 8000.

## Setup port-forwarding

# Install ngrok
!wget -q https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
!unzip -q ngrok-stable-linux-amd64.zip

# Set ngrok authtoken once per-session
!./ngrok authtoken <NGROK_AUTH_TOKEN>
# Replace <NGROK_AUTH_TOKEN> with a token.

# Start an HTTP tunnel forwarding to your local port 8000
get_ipython().system_raw('./ngrok http 8000 &')

# Open a local host port and extract the URL
!curl -s http://localhost:4040/api/tunnels | python3 -c \
    "import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])"
image
Dominant language
Python
Stars
1.8k
Forks
135
Avg merge
2d 18h
Merged PRs (30d)
21

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from posit-dev/py-shiny

All issues in posit-dev/py-shiny

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.