You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once the Positron Python extension has determined a user is in an app, there should be a "Run App" option (perhaps with a "Debug App" option as well) in the play button. Clicking this button should call the appropriate command for the app framework in a new terminal instance.
This PR adds support for local Python application development for the
following frameworks:
* Streamlit
* Dash
* Gradio
* FastAPI
* Flask
This is facilitated by a new extension: `positron-run-app`.
Addresses #4557,
#4555, #3023, #3027, #3024.
https://github.com/user-attachments/assets/d72e5028-a8c9-4aab-b927-4413c4e74b24
### QA notes
1. Open an application developed using one of the supported frameworks.
2. Run the relevant "Python: Run X App in Terminal" command. It should
also be the default action if you click the run button in the editor
menu.
3. It should create a terminal named after the framework, and
automatically show the app in the Viewer pane once its ready.
Here are example apps for all of the supported frameworks:
#### Streamlit
```python
import streamlit as st
x = st.slider('x')
st.write(x, 'squared is', x * x)
```
#### Dash
```python
from dash import Dash, html
app = Dash()
app.layout = [html.Div(children='Hello World')]
if __name__ == '__main__':
app.run(debug=True)
```
#### Gradio
```python
import gradio as gr
def image_classifier(inp):
return {'cat': 0.3, 'dog': 0.7}
demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label")
demo.launch()
```
#### FastAPI
```python
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
```
#### Flask
```python
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello_world():
return "<p>Hello, World!</p>"
```
### Next steps: Workbench integration
To support Workbench, we'll need to update `runApplication` to detect if
we're in Workbench, and if so, find a free port and corresponding
proxied URL (possibly related to
#4274) and pass them both to
`getTerminalOptions`.
Once the Positron Python extension has determined a user is in an app, there should be a "Run App" option (perhaps with a "Debug App" option as well) in the play button. Clicking this button should call the appropriate command for the app framework in a new terminal instance.
Related to #4555 #3023 #3025 #3024 #3027
The text was updated successfully, but these errors were encountered: