Anant0712 commited on
Commit
ecc1d64
·
verified ·
1 Parent(s): f0feec3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -15
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import gradio as gr
2
  import yfinance as yf
3
  import pandas as pd
@@ -79,9 +80,9 @@ def signup_user(username, password):
79
  return "Signup Successful! You can now log in."
80
 
81
  # Gradio Interface
82
- with gr.Blocks(css=".gradio-container {background-color: #f5f5f5; padding: 20px;}") as demo:
83
- # Welcome Page (Splash Screen)
84
- with gr.Blocks() as welcome_page:
85
  gr.Image("/mnt/data/wolf-logo-vector-27048037.jpg", elem_id="welcome-img", label="Logo")
86
  gr.Markdown("""
87
  # Welcome to Stock Anomaly Detection
@@ -130,15 +131,11 @@ with gr.Blocks(css=".gradio-container {background-color: #f5f5f5; padding: 20px;
130
  </div>
131
  """)
132
 
133
- # Add JavaScript to switch between Welcome Page and Main App
134
- demo.load(lambda: (gr.update(visible=False), gr.update(visible=True)), None, [welcome_page, main_app], _js="""
135
- function() {
136
- setTimeout(() => {
137
- document.querySelector('[id^="welcome_page"]').style.display = 'none';
138
- document.querySelector('[id^="main_app"]').style.display = 'block';
139
- }, 2000); // 2 seconds delay
140
- return [];
141
- }
142
- """)
143
-
144
- demo.launch(share=True)
 
1
+ import time
2
  import gradio as gr
3
  import yfinance as yf
4
  import pandas as pd
 
80
  return "Signup Successful! You can now log in."
81
 
82
  # Gradio Interface
83
+ with gr.Blocks(css=".gradio-container {background-color: #f5f5f5; padding: 20px;}") as app:
84
+ # Splash Screen
85
+ with gr.Blocks() as splash_screen:
86
  gr.Image("/mnt/data/wolf-logo-vector-27048037.jpg", elem_id="welcome-img", label="Logo")
87
  gr.Markdown("""
88
  # Welcome to Stock Anomaly Detection
 
131
  </div>
132
  """)
133
 
134
+ # Custom function to handle splash screen timeout
135
+ def splash_timeout():
136
+ time.sleep(2) # Display splash screen for 2 seconds
137
+ return gr.update(visible=False), gr.update(visible=True)
138
+
139
+ splash_screen.load(splash_timeout, inputs=None, outputs=[splash_screen, main_app])
140
+
141
+ app.launch(share=True)