ppsingh commited on
Commit
b9ffe28
·
verified ·
1 Parent(s): 43e8870

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -0
app.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # Define the HTML template for embedding an external Hugging Face Space
4
+ # Replace <space-url> with your actual Space URLs (e.g., "https://hf.co/spaces/user/app-name")
5
+ def embed_space(space_url: str, height: int = 800) -> gr.HTML:
6
+ """Creates a Gradio HTML component to embed an external HF Space via iframe."""
7
+ iframe_html = f"""
8
+ <iframe
9
+ src="{space_url}?view=inline"
10
+ width="100%"
11
+ height="{height}px"
12
+ allow="microphone; camera; clipboard-read; clipboard-write;"
13
+ frameborder="0"
14
+ ></iframe>
15
+ """
16
+ return gr.HTML(iframe_html)
17
+
18
+ # --- Define the Layout ---
19
+ with gr.Blocks(theme=gr.themes.Monochrome()) as dashboard_app:
20
+ gr.Markdown(
21
+ """
22
+ # 🚀 Professional ML Dashboard Hub
23
+ Welcome to the central hub for all our machine learning applications.
24
+ """
25
+ )
26
+
27
+ with gr.Tabs():
28
+
29
+ # 1. Local App Tab (Integrated Directly)
30
+ # This is for apps whose code is running within this main Gradio instance
31
+ with gr.Tab("Data Analyzer"):
32
+ gr.Markdown("## Local Data Analysis Tool")
33
+
34
+ with gr.Row():
35
+ name_input = gr.Textbox(label="Enter Name")
36
+ greeting_output = gr.Textbox(label="Greeting")
37
+
38
+ def greet(name):
39
+ return f"Hello, {name}! Ready to analyze your data."
40
+
41
+ name_input.change(fn=greet, inputs=name_input, outputs=greeting_output)
42
+
43
+ # 2. External Space 1 Tab (Embedded via iframe)
44
+ # Replace the placeholder URL with your actual Space URL
45
+ with gr.Tab("Image Classifier"):
46
+ gr.Markdown("## External Image Classification Space")
47
+ embed_space("https://hf.co/spaces/gradio/image-classification", height=700)
48
+
49
+ # 3. External Space 2 Tab (Embedded via iframe)
50
+ # Replace the placeholder URL with your actual Space URL
51
+ with gr.Tab("LLM Chatbot"):
52
+ gr.Markdown("## External LLM Chatbot Space")
53
+ embed_space("https://hf.co/spaces/HuggingFaceH4/open-llm-leaderboard", height=700)
54
+
55
+ # Launch the app
56
+ dashboard_app.launch()