Created
December 27, 2024 02:37
-
-
Save eliasdabbas/88e2e49e6ea59b74656fd0bdad3b0019 to your computer and use it in GitHub Desktop.
A demo Dash app demonstrating how to run uv scripts remotely
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /// 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is a quick tutorial on how to run Python scripts with uv if you're interested.