Skip to content

Instantly share code, notes, and snippets.

@eliasdabbas
Created December 27, 2024 02:37
Show Gist options
  • Save eliasdabbas/88e2e49e6ea59b74656fd0bdad3b0019 to your computer and use it in GitHub Desktop.
Save eliasdabbas/88e2e49e6ea59b74656fd0bdad3b0019 to your computer and use it in GitHub Desktop.
A demo Dash app demonstrating how to run uv scripts remotely
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "dash",
# "dash-bootstrap-components",
# ]
# ///
from dash import Dash, html, dcc, Output, Input
import dash_bootstrap_components as dbc
app = Dash(external_stylesheets=[dbc.themes.COSMO])
app.layout = html.Div([
html.Br(),
html.H1("Dash app hosted online!"),
html.H2("Choose a color:"),
dcc.Dropdown(id="dropdown", options=["Green", "Blue", "Yellow", "Red"]),
html.Br(),
html.Div(id="output"),
], style={"marginLeft": "5%", "marginRight": "5%"})
@app.callback(Output("output", "children"), Input("dropdown", "value"))
def display_chosen(color):
if not color:
return "You chose nothing yet..."
return html.Span([f"You chose the color: ", html.Span(f"{color}", style={"color": color})], style={"fontSize": "24pt"})
if __name__ == "__main__":
app.run()
@eliasdabbas
Copy link
Author

Here is a quick tutorial on how to run Python scripts with uv if you're interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment