Spaces:
Running
Running
Upload 3 files
Browse filesthree main files
- app.py +33 -0
- requirements.txt +1 -0
- space.yaml +2 -0
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from dash import Dash, dcc, html, Input, Output
|
2 |
+
|
3 |
+
# Create the Dash app
|
4 |
+
app = Dash(__name__)
|
5 |
+
|
6 |
+
# Layout of the app
|
7 |
+
app.layout = html.Div([html.H1("✌️يا هلا بالشباب✌️\n"),
|
8 |
+
# html.Br(),
|
9 |
+
dcc.Input(id='input-text-1', value='ذكر ام انثي؟', type='text'),
|
10 |
+
dcc.Input(id='input-text-2', value='Your name', type='text'),
|
11 |
+
html.Br(), # line break
|
12 |
+
html.Br(),
|
13 |
+
html.Div(id='output-text')
|
14 |
+
])
|
15 |
+
|
16 |
+
# Define the callback function
|
17 |
+
@app.callback(
|
18 |
+
Output('output-text', 'children'), # What gets updated
|
19 |
+
Input('input-text-1', 'value'), # First input trigger
|
20 |
+
Input('input-text-2', 'value') # Second input trigger
|
21 |
+
)
|
22 |
+
def update_output(input1, input2):
|
23 |
+
if input1.lower()=="m" or input1.lower()=="male":
|
24 |
+
title="Mr"
|
25 |
+
elif input1.lower()=="f" or input1.lower()=="female":
|
26 |
+
title="Miss"
|
27 |
+
else:
|
28 |
+
title=" "
|
29 |
+
return f'Hello to your 1st web app, {title} {input2} 😊😊😊'
|
30 |
+
|
31 |
+
# Run the app
|
32 |
+
if __name__ == '__main__': # the main() function will execute only if the script is run directly.
|
33 |
+
app.run_server(debug=True)
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
dash>=2.6.1,<3.0.0
|
space.yaml
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
sdk: gradio
|
2 |
+
app_file: app.py
|