Spaces:
Sleeping
Sleeping
Rowan Martnishn
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -247,25 +247,29 @@ body, .gradio-container {
|
|
247 |
|
248 |
|
249 |
with gr.Blocks(css=custom_css) as demo:
|
250 |
-
# Initialize
|
251 |
-
|
252 |
|
253 |
-
# Define the refresh function
|
254 |
def refresh_html():
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
return "Processing data..."
|
263 |
|
264 |
-
# Use the Timer component
|
265 |
-
timer = gr.Timer(
|
|
|
|
|
|
|
|
|
|
|
266 |
|
267 |
# Initial call to set the HTML content when the page loads
|
268 |
-
demo.load(refresh_html,
|
269 |
|
270 |
# Launch the demo
|
271 |
demo.launch()
|
|
|
247 |
|
248 |
|
249 |
with gr.Blocks(css=custom_css) as demo:
|
250 |
+
# Initialize a placeholder for the loaded space
|
251 |
+
space_placeholder = gr.HTML("Loading space...")
|
252 |
|
253 |
+
# Define the refresh function to call load_space()
|
254 |
def refresh_html():
|
255 |
+
try:
|
256 |
+
# Load the space
|
257 |
+
space = load_space()
|
258 |
+
# Return the rendered HTML of the space
|
259 |
+
return space.render()
|
260 |
+
except Exception as e:
|
261 |
+
return f"Error loading space: {str(e)}"
|
|
|
262 |
|
263 |
+
# Use the Timer component to refresh the HTML every hour (3600 seconds)
|
264 |
+
timer = gr.Timer(
|
265 |
+
every=3600, # Interval in seconds (1 hour)
|
266 |
+
fn=refresh_html, # Function to call
|
267 |
+
inputs=None, # No inputs
|
268 |
+
outputs=space_placeholder, # Output to update
|
269 |
+
)
|
270 |
|
271 |
# Initial call to set the HTML content when the page loads
|
272 |
+
demo.load(refresh_html, inputs=None, outputs=space_placeholder)
|
273 |
|
274 |
# Launch the demo
|
275 |
demo.launch()
|