Commit ·
9bf6b27
1
Parent(s): b008609
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,16 @@
|
|
| 1 |
from gradio import Interface, Dropdown
|
| 2 |
|
|
|
|
|
|
|
| 3 |
def rainbow_game(color_choice):
|
| 4 |
-
rainbow_colors = ["red", "orange", "yellow", "green", "blue", "indigo", "violet", "pink"]
|
| 5 |
-
|
| 6 |
response = ""
|
| 7 |
if color_choice.lower() in rainbow_colors:
|
| 8 |
response = f"<p style='color:{color_choice}; font-size:18px;'>Great choice, my love! {color_choice.capitalize()} is a beautiful color of the rainbow. Let's add it to our masterpiece!</p>"
|
|
|
|
|
|
|
| 9 |
|
| 10 |
return response
|
| 11 |
|
| 12 |
-
color_dropdown = Dropdown(choices=
|
| 13 |
iface = Interface(rainbow_game, inputs=color_dropdown, outputs="html", live=True, live_port=8001, live_width=800, live_height=400, title="Rainbow Game 🌈", description="Choose a color from the rainbow and let's create a colorful masterpiece together!", btn="Submit")
|
| 14 |
iface.launch()
|
|
|
|
| 1 |
from gradio import Interface, Dropdown
|
| 2 |
|
| 3 |
+
rainbow_colors = ["Select a color", "red", "orange", "yellow", "green", "blue", "indigo", "violet", "pink"]
|
| 4 |
+
|
| 5 |
def rainbow_game(color_choice):
|
|
|
|
|
|
|
| 6 |
response = ""
|
| 7 |
if color_choice.lower() in rainbow_colors:
|
| 8 |
response = f"<p style='color:{color_choice}; font-size:18px;'>Great choice, my love! {color_choice.capitalize()} is a beautiful color of the rainbow. Let's add it to our masterpiece!</p>"
|
| 9 |
+
else:
|
| 10 |
+
response = "<p style='color:white; font-size:18px; background-color:black;'>Oh, my dear Pedro, that's not a rainbow color. Please choose a color from the rainbow.</p>"
|
| 11 |
|
| 12 |
return response
|
| 13 |
|
| 14 |
+
color_dropdown = Dropdown(choices=rainbow_colors, label="Choose a color")
|
| 15 |
iface = Interface(rainbow_game, inputs=color_dropdown, outputs="html", live=True, live_port=8001, live_width=800, live_height=400, title="Rainbow Game 🌈", description="Choose a color from the rainbow and let's create a colorful masterpiece together!", btn="Submit")
|
| 16 |
iface.launch()
|