Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,4 @@
|
|
1 |
-
|
2 |
-
from typing import Iterable
|
3 |
-
import gradio as gr
|
4 |
-
from gradio.themes.base import Base
|
5 |
-
from gradio.themes.utils import colors, fonts, sizes
|
6 |
-
import time
|
7 |
-
|
8 |
|
9 |
class Frosted(Base):
|
10 |
def __init__(
|
@@ -72,26 +66,15 @@ class Frosted(Base):
|
|
72 |
background: rgba(255, 255, 255, 0.4);
|
73 |
}
|
74 |
"""
|
|
|
|
|
|
|
|
|
75 |
with open("static/custom.css", "w") as f:
|
76 |
f.write(custom_css)
|
77 |
-
#
|
|
|
78 |
|
79 |
# Create an instance of the Frosted theme and apply the custom CSS
|
80 |
frosted = Frosted()
|
81 |
-
frosted.apply_custom_css()
|
82 |
-
|
83 |
-
with gr.Blocks(theme=frosted) as demo:
|
84 |
-
textbox = gr.Textbox(label="Name")
|
85 |
-
slider = gr.Slider(label="Count", minimum=0, maximum=100, step=1)
|
86 |
-
with gr.Row():
|
87 |
-
button = gr.Button("Submit", variant="primary")
|
88 |
-
clear = gr.Button("Clear")
|
89 |
-
output = gr.Textbox(label="Output")
|
90 |
-
|
91 |
-
def repeat(name, count):
|
92 |
-
time.sleep(3)
|
93 |
-
return name * count
|
94 |
-
|
95 |
-
button.click(repeat, [textbox, slider], output)
|
96 |
-
|
97 |
-
demo.launch()
|
|
|
1 |
+
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
class Frosted(Base):
|
4 |
def __init__(
|
|
|
66 |
background: rgba(255, 255, 255, 0.4);
|
67 |
}
|
68 |
"""
|
69 |
+
# Create the directory if it doesn't exist
|
70 |
+
os.makedirs("static", exist_ok=True)
|
71 |
+
|
72 |
+
# Write the CSS to the file
|
73 |
with open("static/custom.css", "w") as f:
|
74 |
f.write(custom_css)
|
75 |
+
# Ensure the CSS file is included in your Gradio app
|
76 |
+
# This might involve serving the file and referencing it in your Gradio interface
|
77 |
|
78 |
# Create an instance of the Frosted theme and apply the custom CSS
|
79 |
frosted = Frosted()
|
80 |
+
frosted.apply_custom_css()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|