Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python web applications should run in the Viewer #1302

Closed
gshotwell opened this issue Sep 13, 2023 · 3 comments
Closed

Python web applications should run in the Viewer #1302

gshotwell opened this issue Sep 13, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request lang: python

Comments

@gshotwell
Copy link

This is maybe a bit of a tricky feature, but it would be great if we could support running Python web applications in the Viewer. Currently they run in various places using the language-specific CLI, but unifying those into a single experience would be powerful. To my knowledge none of the available IDEs do a good job of previewing these apps alongside the source code.

The frameworks I'd recommend supporting are:

  • Gradio
  • Streamlit
  • Dash
  • Panel
  • Shiny for Python (Currently runs in simple browser)
@jmcphers
Copy link
Collaborator

I looked at the source code for some of these and found that most of them don't give you the ability to set a launch hook, so automatically opening the Viewer when one of these applications starts is pretty tough and will probably require some bailing wire and heuristic behavior.

Some breadcrumbs:

  • Some of these use webbrowser to open a web browser. We can register a web browser controller with webbrowser and make it the default, so that web applications open in our viewer by default.
  • Almost all emit a link to the launched application. We could detect that link and make it easy to open in our Viewer by clicking on it in the Console.
  • Workbench deals with this in the most brute-force way -- scanning for new localhost servers/ports on the system, sort of the network equivalent of screen scraping.

@isabelizimm
Copy link
Contributor

isabelizimm commented May 6, 2024

As of today, the experience is:

  • If the web application is run from the Console and uses webbrowser to open, it will automatically be opened. If not, the outputted link (if there is one) can be clicked and users will be prompted to open it in the Viewer pane.
  • If the web application is run in the Terminal, the outputted link (if there is one) can be clicked and users will be prompted to open it in the Viewer pane

The rest of this issue will be implemented per-framework:

Shiny for Python is omitted from the list since the experience is quite nice via the Shiny VSCode extension, which is compatible with Positron.

@juliasilge
Copy link
Contributor

In Positron 2024.05.0 (Universal) build 1151, I can confirm both that webbrowser web apps open automatically in the Viewer, and that I web apps run in the terminal can be opened in the Viewer by clicking the URL:

Image

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request lang: python
Projects
None yet
Development

No branches or pull requests

6 participants